{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Exploring Library Usage in San Francisco\n",
    "\n",
    "## Project Start Date: 3/8/2018\n",
    "\n",
    "## Analyst: Ted Petrou\n",
    "\n",
    "## Summary\n",
    "In this notebook, we will follow the outline from the **First Look at Data** section onwards. We will systematically explore the basic facets of the data. This is just a starting point for our analysis and will be used as a launching point for future investigation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load libraries\n",
    "The vast majority (or sometimes all) the analysis for this routine can be completed with just pandas. NumPy can help with a few rare cases where no available pandas method exists or where increase in performance is necessary.\n",
    "\n",
    "Pandas can also make a few, but very common, visualizations. Seaborn is imported to make a few different and more aethstetically pleasing visualizations."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import seaborn as sns\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "library = pd.read_csv('data/library_usage.csv')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## First glance at data\n",
    "Use the `head` or `tail` commands to display the first/last rows of data. JupyterLab now has the ability to display csv files, so you can permanently keep the dataset open to browse at your liking while simultaneously working in the notebook."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Patron Type Code</th>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>Total Checkouts</th>\n",
       "      <th>Total Renewals</th>\n",
       "      <th>Age Range</th>\n",
       "      <th>Home Library Code</th>\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Circulation Active Month</th>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>Provided Email Address</th>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <th>Outside of County</th>\n",
       "      <th>Supervisor District</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3</td>\n",
       "      <td>SENIOR</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "      <td>65 to 74 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>November</td>\n",
       "      <td>2012</td>\n",
       "      <td>z</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>ADULT</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>55 to 59 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>October</td>\n",
       "      <td>2015</td>\n",
       "      <td>z</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>ADULT</td>\n",
       "      <td>275</td>\n",
       "      <td>559</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>January</td>\n",
       "      <td>2015</td>\n",
       "      <td>z</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>ADULT</td>\n",
       "      <td>73</td>\n",
       "      <td>38</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>M8</td>\n",
       "      <td>Mission Bay</td>\n",
       "      <td>February</td>\n",
       "      <td>2016</td>\n",
       "      <td>z</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>ADULT</td>\n",
       "      <td>182</td>\n",
       "      <td>90</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>July</td>\n",
       "      <td>2016</td>\n",
       "      <td>z</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Patron Type Code Patron Type Definition  Total Checkouts  Total Renewals  \\\n",
       "0                 3                 SENIOR               28              13   \n",
       "1                 0                  ADULT               21              10   \n",
       "2                 0                  ADULT              275             559   \n",
       "3                 0                  ADULT               73              38   \n",
       "4                 0                  ADULT              182              90   \n",
       "\n",
       "        Age Range Home Library Code Home Library Definition  \\\n",
       "0  65 to 74 years                 X            Main Library   \n",
       "1  55 to 59 years                 X            Main Library   \n",
       "2  60 to 64 years                 X            Main Library   \n",
       "3  45 to 54 years                M8             Mission Bay   \n",
       "4  45 to 54 years                 X            Main Library   \n",
       "\n",
       "  Circulation Active Month Circulation Active Year Notice Preference Code  \\\n",
       "0                 November                    2012                      z   \n",
       "1                  October                    2015                      z   \n",
       "2                  January                    2015                      z   \n",
       "3                 February                    2016                      z   \n",
       "4                     July                    2016                      z   \n",
       "\n",
       "  Notice Preference Definition  Provided Email Address  \\\n",
       "0                        email                    True   \n",
       "1                        email                    True   \n",
       "2                        email                    True   \n",
       "3                        email                    True   \n",
       "4                        email                    True   \n",
       "\n",
       "   Year Patron Registered  Outside of County  Supervisor District  \n",
       "0                    2003               True                  NaN  \n",
       "1                    2003              False                  NaN  \n",
       "2                    2003               True                  NaN  \n",
       "3                    2003              False                  NaN  \n",
       "4                    2003              False                  NaN  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Studying the data dictionary\n",
    "Its important to take a close look at the data dictionary to get a solid understanding of each column.\n",
    "\n",
    "## What if there is no data dictionary?\n",
    "It is your job to find one or create one. I suggest asking database admins or searching online before attempting to create one yourself.\n",
    "\n",
    "## Do you upkeep the data dictionary by hand or in pandas?\n",
    "Pandas is not specifically designed for keeping notes in cells but it can be done somewhat pain-free. Pandas does however, allow you to add metadata very easily to columns. I will use pandas to keep all the notes and metadata. Using a spreadsheet is also acceptable and allows you to make edits a bit faster."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Loading the data dictionary as a DataFrame\n",
    "I converted the original data dictionary as an Excel file to a csv so that I could easily load it into pandas."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Field Name</th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes (optional)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Patron Type Code</td>\n",
       "      <td>Numeric</td>\n",
       "      <td>Type of patron record (adult, teen, child, sen...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Patron Type Definition</td>\n",
       "      <td>Text</td>\n",
       "      <td>Description of patron (adult, teen, child, sen...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Total Checkouts</td>\n",
       "      <td>Numeric</td>\n",
       "      <td>Total number of items the patron has checked o...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Total Renewals</td>\n",
       "      <td>Numeric</td>\n",
       "      <td>Total number of times the patron has renewed c...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Birth Date</td>\n",
       "      <td>Text</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 t...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Home Library Code</td>\n",
       "      <td>Text</td>\n",
       "      <td>Default value indicates the branch library whe...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Home Library Definition</td>\n",
       "      <td>Text</td>\n",
       "      <td>Description of the branch library where the pa...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Circulation Active Year</td>\n",
       "      <td>Text</td>\n",
       "      <td>Year the patron last checked out library mater...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Notice Preference Code</td>\n",
       "      <td>Text</td>\n",
       "      <td>This field is used to indicate the patron’s pr...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Notice Preference Definition</td>\n",
       "      <td>Text</td>\n",
       "      <td>Description of the patron’s preferred method o...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Provided Email Address</td>\n",
       "      <td>Boolean (True/False)</td>\n",
       "      <td>Indicates whether the patron provided an email...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Year Patron Registered</td>\n",
       "      <td>Text</td>\n",
       "      <td>Year patron registered with library system. No...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Outside of County</td>\n",
       "      <td>Boolean (True/False)</td>\n",
       "      <td>If a patron's home address is not in San Franc...</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Supervisor District</td>\n",
       "      <td>Numeric</td>\n",
       "      <td>Based on patron address: San Francisco Supervi...</td>\n",
       "      <td>This is an automated field, please note that i...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      Field Name             Data Type  \\\n",
       "0               Patron Type Code               Numeric   \n",
       "1         Patron Type Definition                  Text   \n",
       "2                Total Checkouts               Numeric   \n",
       "3                 Total Renewals               Numeric   \n",
       "4                     Birth Date                  Text   \n",
       "5              Home Library Code                  Text   \n",
       "6        Home Library Definition                  Text   \n",
       "7        Circulation Active Year                  Text   \n",
       "8         Notice Preference Code                  Text   \n",
       "9   Notice Preference Definition                  Text   \n",
       "10        Provided Email Address  Boolean (True/False)   \n",
       "11        Year Patron Registered                  Text   \n",
       "12             Outside of County  Boolean (True/False)   \n",
       "13           Supervisor District               Numeric   \n",
       "\n",
       "                                           Definition  \\\n",
       "0   Type of patron record (adult, teen, child, sen...   \n",
       "1   Description of patron (adult, teen, child, sen...   \n",
       "2   Total number of items the patron has checked o...   \n",
       "3   Total number of times the patron has renewed c...   \n",
       "4   Age ranges: 0 to 9 years, 10 to 19 years, 20 t...   \n",
       "5   Default value indicates the branch library whe...   \n",
       "6   Description of the branch library where the pa...   \n",
       "7   Year the patron last checked out library mater...   \n",
       "8   This field is used to indicate the patron’s pr...   \n",
       "9   Description of the patron’s preferred method o...   \n",
       "10  Indicates whether the patron provided an email...   \n",
       "11  Year patron registered with library system. No...   \n",
       "12  If a patron's home address is not in San Franc...   \n",
       "13  Based on patron address: San Francisco Supervi...   \n",
       "\n",
       "                                     Notes (optional)  \n",
       "0                                                 NaN  \n",
       "1                                                 NaN  \n",
       "2                                                 NaN  \n",
       "3                                                 NaN  \n",
       "4                                                 NaN  \n",
       "5                                                 NaN  \n",
       "6                                                 NaN  \n",
       "7                                                 NaN  \n",
       "8                                                 NaN  \n",
       "9                                                 NaN  \n",
       "10                                                NaN  \n",
       "11                                                NaN  \n",
       "12                                                NaN  \n",
       "13  This is an automated field, please note that i...  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd = pd.read_csv('data/Data Dictionary.csv')\n",
    "library_dd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "50"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.options.display.max_colwidth"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.options.display.max_colwidth = 200"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Field Name</th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes (optional)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Patron Type Code</td>\n",
       "      <td>Numeric</td>\n",
       "      <td>Type of patron record (adult, teen, child, senior, etc.) Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Patron Type Definition</td>\n",
       "      <td>Text</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Total Checkouts</td>\n",
       "      <td>Numeric</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Total Renewals</td>\n",
       "      <td>Numeric</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Birth Date</td>\n",
       "      <td>Text</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Home Library Code</td>\n",
       "      <td>Text</td>\n",
       "      <td>Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Home Library Definition</td>\n",
       "      <td>Text</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Circulation Active Year</td>\n",
       "      <td>Text</td>\n",
       "      <td>Year the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Notice Preference Code</td>\n",
       "      <td>Text</td>\n",
       "      <td>This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Notice Preference Definition</td>\n",
       "      <td>Text</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Provided Email Address</td>\n",
       "      <td>Boolean (True/False)</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Year Patron Registered</td>\n",
       "      <td>Text</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Outside of County</td>\n",
       "      <td>Boolean (True/False)</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Supervisor District</td>\n",
       "      <td>Numeric</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      Field Name             Data Type  \\\n",
       "0               Patron Type Code               Numeric   \n",
       "1         Patron Type Definition                  Text   \n",
       "2                Total Checkouts               Numeric   \n",
       "3                 Total Renewals               Numeric   \n",
       "4                     Birth Date                  Text   \n",
       "5              Home Library Code                  Text   \n",
       "6        Home Library Definition                  Text   \n",
       "7        Circulation Active Year                  Text   \n",
       "8         Notice Preference Code                  Text   \n",
       "9   Notice Preference Definition                  Text   \n",
       "10        Provided Email Address  Boolean (True/False)   \n",
       "11        Year Patron Registered                  Text   \n",
       "12             Outside of County  Boolean (True/False)   \n",
       "13           Supervisor District               Numeric   \n",
       "\n",
       "                                                                                                                                                                                 Definition  \\\n",
       "0                                                                                                                      Type of patron record (adult, teen, child, senior, etc.) Some blank.   \n",
       "1                                                                                                                                  Description of patron (adult, teen, child, senior, etc.)   \n",
       "2                                                                                           Total number of items the patron has checked out from the library since the record was created.   \n",
       "3                                                                                                                           Total number of times the patron has renewed checked-out items.   \n",
       "4   Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "5                               Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.   \n",
       "6                                                                                                             Description of the branch library where the patron was originally registered.   \n",
       "7                                         Year the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "8                                                              This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.   \n",
       "9                                                                                                                Description of the patron’s preferred method of receiving library notices.   \n",
       "10                                                                                                                                   Indicates whether the patron provided an email address   \n",
       "11                                                                                              Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "12                                                                                               If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "13                                                                                                                              Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                           Notes (optional)  \n",
       "0                                                                                                                                                                                                       NaN  \n",
       "1                                                                                                                                                                                                       NaN  \n",
       "2                                                                                                                                                                                                       NaN  \n",
       "3                                                                                                                                                                                                       NaN  \n",
       "4                                                                                                                                                                                                       NaN  \n",
       "5                                                                                                                                                                                                       NaN  \n",
       "6                                                                                                                                                                                                       NaN  \n",
       "7                                                                                                                                                                                                       NaN  \n",
       "8                                                                                                                                                                                                       NaN  \n",
       "9                                                                                                                                                                                                       NaN  \n",
       "10                                                                                                                                                                                                      NaN  \n",
       "11                                                                                                                                                                                                      NaN  \n",
       "12                                                                                                                                                                                                      NaN  \n",
       "13  This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Pandas data types\n",
    "The data types in the official data dictionary are generic and not specific to pandas. Instead of using this default data dictinoary, we can create our own. Let's first copy it into a new variable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "library_dd_pandas = library_dd.copy()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Replace the generic data types with pandas data types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Patron Type Code                  int64\n",
       "Patron Type Definition           object\n",
       "Total Checkouts                   int64\n",
       "Total Renewals                    int64\n",
       "Age Range                        object\n",
       "Home Library Code                object\n",
       "Home Library Definition          object\n",
       "Circulation Active Month         object\n",
       "Circulation Active Year          object\n",
       "Notice Preference Code           object\n",
       "Notice Preference Definition     object\n",
       "Provided Email Address             bool\n",
       "Year Patron Registered            int64\n",
       "Outside of County                  bool\n",
       "Supervisor District             float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "library_dd_pandas['Data Type'] = library.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Field Name</th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes (optional)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Patron Type Code</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Type of patron record (adult, teen, child, senior, etc.) Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Patron Type Definition</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Total Checkouts</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Total Renewals</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Birth Date</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Home Library Code</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Home Library Definition</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Circulation Active Year</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Year the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Notice Preference Code</td>\n",
       "      <td>NaN</td>\n",
       "      <td>This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Notice Preference Definition</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Provided Email Address</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Year Patron Registered</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Outside of County</td>\n",
       "      <td>NaN</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Supervisor District</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      Field Name Data Type  \\\n",
       "0               Patron Type Code       NaN   \n",
       "1         Patron Type Definition       NaN   \n",
       "2                Total Checkouts       NaN   \n",
       "3                 Total Renewals       NaN   \n",
       "4                     Birth Date       NaN   \n",
       "5              Home Library Code       NaN   \n",
       "6        Home Library Definition       NaN   \n",
       "7        Circulation Active Year       NaN   \n",
       "8         Notice Preference Code       NaN   \n",
       "9   Notice Preference Definition       NaN   \n",
       "10        Provided Email Address       NaN   \n",
       "11        Year Patron Registered       NaN   \n",
       "12             Outside of County       NaN   \n",
       "13           Supervisor District       NaN   \n",
       "\n",
       "                                                                                                                                                                                 Definition  \\\n",
       "0                                                                                                                      Type of patron record (adult, teen, child, senior, etc.) Some blank.   \n",
       "1                                                                                                                                  Description of patron (adult, teen, child, senior, etc.)   \n",
       "2                                                                                           Total number of items the patron has checked out from the library since the record was created.   \n",
       "3                                                                                                                           Total number of times the patron has renewed checked-out items.   \n",
       "4   Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "5                               Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.   \n",
       "6                                                                                                             Description of the branch library where the patron was originally registered.   \n",
       "7                                         Year the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "8                                                              This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.   \n",
       "9                                                                                                                Description of the patron’s preferred method of receiving library notices.   \n",
       "10                                                                                                                                   Indicates whether the patron provided an email address   \n",
       "11                                                                                              Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "12                                                                                               If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "13                                                                                                                              Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                           Notes (optional)  \n",
       "0                                                                                                                                                                                                       NaN  \n",
       "1                                                                                                                                                                                                       NaN  \n",
       "2                                                                                                                                                                                                       NaN  \n",
       "3                                                                                                                                                                                                       NaN  \n",
       "4                                                                                                                                                                                                       NaN  \n",
       "5                                                                                                                                                                                                       NaN  \n",
       "6                                                                                                                                                                                                       NaN  \n",
       "7                                                                                                                                                                                                       NaN  \n",
       "8                                                                                                                                                                                                       NaN  \n",
       "9                                                                                                                                                                                                       NaN  \n",
       "10                                                                                                                                                                                                      NaN  \n",
       "11                                                                                                                                                                                                      NaN  \n",
       "12                                                                                                                                                                                                      NaN  \n",
       "13  This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_pandas"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## What went wrong?\n",
    "Pandas aligns first on the index (the labels on the left in **bold**) of each object. `library.dtypes` has the **column names** as the index. The data dictionary just has **integers**. No alignment happens and missing values are the result.\n",
    "\n",
    "## Move column name into the index\n",
    "We can move the column names into the index from **`library_dd_pandas`** so that all future column data is automatically aligned properly."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes (optional)</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Code</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Type of patron record (adult, teen, child, senior, etc.) Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Birth Date</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Code</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Year the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <td>NaN</td>\n",
       "      <td>This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>NaN</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             Data Type  \\\n",
       "Column Name                              \n",
       "Patron Type Code                   NaN   \n",
       "Patron Type Definition             NaN   \n",
       "Total Checkouts                    NaN   \n",
       "Total Renewals                     NaN   \n",
       "Birth Date                         NaN   \n",
       "Home Library Code                  NaN   \n",
       "Home Library Definition            NaN   \n",
       "Circulation Active Year            NaN   \n",
       "Notice Preference Code             NaN   \n",
       "Notice Preference Definition       NaN   \n",
       "Provided Email Address             NaN   \n",
       "Year Patron Registered             NaN   \n",
       "Outside of County                  NaN   \n",
       "Supervisor District                NaN   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Code                                                                                                                                 Type of patron record (adult, teen, child, senior, etc.) Some blank.   \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Birth Date                    Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Code                                         Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Circulation Active Year                                             Year the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Notice Preference Code                                                                   This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                                                     Notes (optional)  \n",
       "Column Name                                                                                                                                                                                                                            \n",
       "Patron Type Code                                                                                                                                                                                                                  NaN  \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN  \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN  \n",
       "Total Renewals                                                                                                                                                                                                                    NaN  \n",
       "Birth Date                                                                                                                                                                                                                        NaN  \n",
       "Home Library Code                                                                                                                                                                                                                 NaN  \n",
       "Home Library Definition                                                                                                                                                                                                           NaN  \n",
       "Circulation Active Year                                                                                                                                                                                                           NaN  \n",
       "Notice Preference Code                                                                                                                                                                                                            NaN  \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN  \n",
       "Provided Email Address                                                                                                                                                                                                            NaN  \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN  \n",
       "Outside of County                                                                                                                                                                                                                 NaN  \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_pandas = library_dd_pandas.rename(columns={'Field Name': 'Column Name'}) \\\n",
    "                                     .set_index('Column Name')\n",
    "library_dd_pandas"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Redo previous operation\n",
    "Now that the indexes are identical, the alignment will "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "library_dd_pandas['Data Type'] = library.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes (optional)</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Code</th>\n",
       "      <td>int64</td>\n",
       "      <td>Type of patron record (adult, teen, child, senior, etc.) Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Birth Date</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Code</th>\n",
       "      <td>object</td>\n",
       "      <td>Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <td>object</td>\n",
       "      <td>Year the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <td>object</td>\n",
       "      <td>This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             Data Type  \\\n",
       "Column Name                              \n",
       "Patron Type Code                 int64   \n",
       "Patron Type Definition          object   \n",
       "Total Checkouts                  int64   \n",
       "Total Renewals                   int64   \n",
       "Birth Date                         NaN   \n",
       "Home Library Code               object   \n",
       "Home Library Definition         object   \n",
       "Circulation Active Year         object   \n",
       "Notice Preference Code          object   \n",
       "Notice Preference Definition    object   \n",
       "Provided Email Address            bool   \n",
       "Year Patron Registered           int64   \n",
       "Outside of County                 bool   \n",
       "Supervisor District            float64   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Code                                                                                                                                 Type of patron record (adult, teen, child, senior, etc.) Some blank.   \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Birth Date                    Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Code                                         Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Circulation Active Year                                             Year the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Notice Preference Code                                                                   This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                                                     Notes (optional)  \n",
       "Column Name                                                                                                                                                                                                                            \n",
       "Patron Type Code                                                                                                                                                                                                                  NaN  \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN  \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN  \n",
       "Total Renewals                                                                                                                                                                                                                    NaN  \n",
       "Birth Date                                                                                                                                                                                                                        NaN  \n",
       "Home Library Code                                                                                                                                                                                                                 NaN  \n",
       "Home Library Definition                                                                                                                                                                                                           NaN  \n",
       "Circulation Active Year                                                                                                                                                                                                           NaN  \n",
       "Notice Preference Code                                                                                                                                                                                                            NaN  \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN  \n",
       "Provided Email Address                                                                                                                                                                                                            NaN  \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN  \n",
       "Outside of County                                                                                                                                                                                                                 NaN  \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_pandas"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## There's still something wrong - Birth Date column has a missing data type!\n",
    "Each column's data type should never be missing, yet we are getting a missing value for the **`Birth Date`** column. This column is named **`Age Range`** in the actual dataset.\n",
    "\n",
    "## Ensure all columns are the same in both DataFrames\n",
    "Let's do a sanity check and see if there are same number of columns in the data as there are descriptions in the data dictionary."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(library.columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "14"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(library_dd_pandas.index)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Failed sanity test\n",
    "We don't even have the same number of values in each one.\n",
    "\n",
    "## Find which values are in one but not the other\n",
    "Use the `isin` method to find which values are in the data dictionary but are not columns in the data and vice-versa:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Birth Date'], dtype='object', name='Column Name')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isin_dd = library_dd_pandas.index.isin(library.columns)\n",
    "library_dd_pandas.index[~isin_dd]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Age Range', 'Circulation Active Month'], dtype='object')"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isin_data = library.columns.isin(library_dd_pandas.index)\n",
    "library.columns[~isin_data]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Conclusions of column name mistakes\n",
    "* **`Birth Date`** from the data dictionary is named **`Age Range`** in the data.\n",
    "* **`Circulation Active Month`** is in the data but absent from the data dictionary.\n",
    "\n",
    "Let's rename **`Birth Date`** in data dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes (optional)</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Code</th>\n",
       "      <td>int64</td>\n",
       "      <td>Type of patron record (adult, teen, child, senior, etc.) Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Code</th>\n",
       "      <td>object</td>\n",
       "      <td>Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <td>object</td>\n",
       "      <td>Year the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <td>object</td>\n",
       "      <td>This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             Data Type  \\\n",
       "Column Name                              \n",
       "Patron Type Code                 int64   \n",
       "Patron Type Definition          object   \n",
       "Total Checkouts                  int64   \n",
       "Total Renewals                   int64   \n",
       "Age Range                          NaN   \n",
       "Home Library Code               object   \n",
       "Home Library Definition         object   \n",
       "Circulation Active Year         object   \n",
       "Notice Preference Code          object   \n",
       "Notice Preference Definition    object   \n",
       "Provided Email Address            bool   \n",
       "Year Patron Registered           int64   \n",
       "Outside of County                 bool   \n",
       "Supervisor District            float64   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Code                                                                                                                                 Type of patron record (adult, teen, child, senior, etc.) Some blank.   \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Code                                         Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Circulation Active Year                                             Year the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Notice Preference Code                                                                   This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                                                     Notes (optional)  \n",
       "Column Name                                                                                                                                                                                                                            \n",
       "Patron Type Code                                                                                                                                                                                                                  NaN  \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN  \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN  \n",
       "Total Renewals                                                                                                                                                                                                                    NaN  \n",
       "Age Range                                                                                                                                                                                                                         NaN  \n",
       "Home Library Code                                                                                                                                                                                                                 NaN  \n",
       "Home Library Definition                                                                                                                                                                                                           NaN  \n",
       "Circulation Active Year                                                                                                                                                                                                           NaN  \n",
       "Notice Preference Code                                                                                                                                                                                                            NaN  \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN  \n",
       "Provided Email Address                                                                                                                                                                                                            NaN  \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN  \n",
       "Outside of County                                                                                                                                                                                                                 NaN  \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_pandas = library_dd_pandas.rename(index={'Birth Date': 'Age Range'})\n",
    "library_dd_pandas"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Insert new row for Circulation Active Month\n",
    "This is tricky and not easily accomplished with pandas. \n",
    "* First, select the **`Circulation Active Year`** row as a **`Series`**\n",
    "* Change the the definition and change the **`name`** which will be used as the new index label."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "circulation_am = library_dd_pandas.loc['Circulation Active Year']\n",
    "circulation_am['Definition'] = 'Month the patron last checked out library materials, ' \\\n",
    "                               'or last logged into the library’s subscription databases ' \\\n",
    "                               'from a computer outside the library.'\n",
    "circulation_am.name = 'Circulation Active Month'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Cut old data dictionary to pieces and splice in new row"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes (optional)</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Code</th>\n",
       "      <td>int64</td>\n",
       "      <td>Type of patron record (adult, teen, child, senior, etc.) Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>NaN</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Code</th>\n",
       "      <td>object</td>\n",
       "      <td>Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Month</th>\n",
       "      <td>object</td>\n",
       "      <td>Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <td>object</td>\n",
       "      <td>Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <td>object</td>\n",
       "      <td>This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             Data Type  \\\n",
       "Column Name                              \n",
       "Patron Type Code                 int64   \n",
       "Patron Type Definition          object   \n",
       "Total Checkouts                  int64   \n",
       "Total Renewals                   int64   \n",
       "Age Range                          NaN   \n",
       "Home Library Code               object   \n",
       "Home Library Definition         object   \n",
       "Circulation Active Month        object   \n",
       "Circulation Active Year         object   \n",
       "Notice Preference Code          object   \n",
       "Notice Preference Definition    object   \n",
       "Provided Email Address            bool   \n",
       "Year Patron Registered           int64   \n",
       "Outside of County                 bool   \n",
       "Supervisor District            float64   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Code                                                                                                                                 Type of patron record (adult, teen, child, senior, etc.) Some blank.   \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Code                                         Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Circulation Active Month                                           Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Circulation Active Year                                            Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Notice Preference Code                                                                   This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                                                     Notes (optional)  \n",
       "Column Name                                                                                                                                                                                                                            \n",
       "Patron Type Code                                                                                                                                                                                                                  NaN  \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN  \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN  \n",
       "Total Renewals                                                                                                                                                                                                                    NaN  \n",
       "Age Range                                                                                                                                                                                                                         NaN  \n",
       "Home Library Code                                                                                                                                                                                                                 NaN  \n",
       "Home Library Definition                                                                                                                                                                                                           NaN  \n",
       "Circulation Active Month                                                                                                                                                                                                          NaN  \n",
       "Circulation Active Year                                                                                                                                                                                                           NaN  \n",
       "Notice Preference Code                                                                                                                                                                                                            NaN  \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN  \n",
       "Provided Email Address                                                                                                                                                                                                            NaN  \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN  \n",
       "Outside of County                                                                                                                                                                                                                 NaN  \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...  "
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 = library_dd_pandas.loc[:'Home Library Definition']\n",
    "df2 = library_dd_pandas.loc['Circulation Active Year':]\n",
    "library_dd_new = df1.append(circulation_am).append(df2)\n",
    "library_dd_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Are we finally ready to align the data?\n",
    "Let's find out one more time and add in the data types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes (optional)</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Code</th>\n",
       "      <td>int64</td>\n",
       "      <td>Type of patron record (adult, teen, child, senior, etc.) Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>object</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Code</th>\n",
       "      <td>object</td>\n",
       "      <td>Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Month</th>\n",
       "      <td>object</td>\n",
       "      <td>Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <td>object</td>\n",
       "      <td>Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <td>object</td>\n",
       "      <td>This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             Data Type  \\\n",
       "Column Name                              \n",
       "Patron Type Code                 int64   \n",
       "Patron Type Definition          object   \n",
       "Total Checkouts                  int64   \n",
       "Total Renewals                   int64   \n",
       "Age Range                       object   \n",
       "Home Library Code               object   \n",
       "Home Library Definition         object   \n",
       "Circulation Active Month        object   \n",
       "Circulation Active Year         object   \n",
       "Notice Preference Code          object   \n",
       "Notice Preference Definition    object   \n",
       "Provided Email Address            bool   \n",
       "Year Patron Registered           int64   \n",
       "Outside of County                 bool   \n",
       "Supervisor District            float64   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Code                                                                                                                                 Type of patron record (adult, teen, child, senior, etc.) Some blank.   \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Code                                         Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Circulation Active Month                                           Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Circulation Active Year                                            Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Notice Preference Code                                                                   This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                                                     Notes (optional)  \n",
       "Column Name                                                                                                                                                                                                                            \n",
       "Patron Type Code                                                                                                                                                                                                                  NaN  \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN  \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN  \n",
       "Total Renewals                                                                                                                                                                                                                    NaN  \n",
       "Age Range                                                                                                                                                                                                                         NaN  \n",
       "Home Library Code                                                                                                                                                                                                                 NaN  \n",
       "Home Library Definition                                                                                                                                                                                                           NaN  \n",
       "Circulation Active Month                                                                                                                                                                                                          NaN  \n",
       "Circulation Active Year                                                                                                                                                                                                           NaN  \n",
       "Notice Preference Code                                                                                                                                                                                                            NaN  \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN  \n",
       "Provided Email Address                                                                                                                                                                                                            NaN  \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN  \n",
       "Outside of County                                                                                                                                                                                                                 NaN  \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new['Data Type'] = library.dtypes\n",
    "library_dd_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Comparing the pandas data types to the original data types\n",
    "All the data types seem to match. Pandas uses the **object** data type to hold text. But, if you look closely, the **`Circulation Active Year`** is text even though it appears to be an integer. We will come back to this later."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Making notes and updating the data dictionary\n",
    "Its quite straightforward to update the data dictionary. We just need to select the exact cell of data with the **`.loc`** indexer and give it a new value.\n",
    "\n",
    "Let's make a note that the **`Circulation Active Month`** was not in the orginal data dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "# rename column Notes (optional) to Notes\n",
    "library_dd_new = library_dd_new.rename(columns={'Notes (optional)': 'Notes'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Code</th>\n",
       "      <td>int64</td>\n",
       "      <td>Type of patron record (adult, teen, child, senior, etc.) Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>object</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Code</th>\n",
       "      <td>object</td>\n",
       "      <td>Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Month</th>\n",
       "      <td>object</td>\n",
       "      <td>Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>This column was not in original data dictionary</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <td>object</td>\n",
       "      <td>Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <td>object</td>\n",
       "      <td>This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             Data Type  \\\n",
       "Column Name                              \n",
       "Patron Type Code                 int64   \n",
       "Patron Type Definition          object   \n",
       "Total Checkouts                  int64   \n",
       "Total Renewals                   int64   \n",
       "Age Range                       object   \n",
       "Home Library Code               object   \n",
       "Home Library Definition         object   \n",
       "Circulation Active Month        object   \n",
       "Circulation Active Year         object   \n",
       "Notice Preference Code          object   \n",
       "Notice Preference Definition    object   \n",
       "Provided Email Address            bool   \n",
       "Year Patron Registered           int64   \n",
       "Outside of County                 bool   \n",
       "Supervisor District            float64   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Code                                                                                                                                 Type of patron record (adult, teen, child, senior, etc.) Some blank.   \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Code                                         Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Circulation Active Month                                           Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Circulation Active Year                                            Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Notice Preference Code                                                                   This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                                                                Notes  \n",
       "Column Name                                                                                                                                                                                                                            \n",
       "Patron Type Code                                                                                                                                                                                                                  NaN  \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN  \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN  \n",
       "Total Renewals                                                                                                                                                                                                                    NaN  \n",
       "Age Range                                                                                                                                                                                                                         NaN  \n",
       "Home Library Code                                                                                                                                                                                                                 NaN  \n",
       "Home Library Definition                                                                                                                                                                                                           NaN  \n",
       "Circulation Active Month                                                                                                                                                              This column was not in original data dictionary  \n",
       "Circulation Active Year                                                                                                                                                                                                           NaN  \n",
       "Notice Preference Code                                                                                                                                                                                                            NaN  \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN  \n",
       "Provided Email Address                                                                                                                                                                                                            NaN  \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN  \n",
       "Outside of County                                                                                                                                                                                                                 NaN  \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...  "
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new.loc['Circulation Active Month', 'Notes'] = 'This column was not in original data dictionary'\n",
    "library_dd_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Continuing on with checklist\n",
    "Find the number of rows and columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(423448, 15)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Get a distribution of the data types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "object     8\n",
       "int64      4\n",
       "bool       2\n",
       "float64    1\n",
       "dtype: int64"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library.dtypes.value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Find the number of missing values per column"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Patron Type Code                     0\n",
       "Patron Type Definition               0\n",
       "Total Checkouts                      0\n",
       "Total Renewals                       0\n",
       "Age Range                          215\n",
       "Home Library Code                   40\n",
       "Home Library Definition              0\n",
       "Circulation Active Month             0\n",
       "Circulation Active Year              0\n",
       "Notice Preference Code               0\n",
       "Notice Preference Definition         0\n",
       "Provided Email Address               0\n",
       "Year Patron Registered               0\n",
       "Outside of County                    0\n",
       "Supervisor District             110310\n",
       "dtype: int64"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library.isna().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Append this as a column to the data dictionary\n",
    "Index alignment helps us out here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes</th>\n",
       "      <th>Missing Values Count</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Code</th>\n",
       "      <td>int64</td>\n",
       "      <td>Type of patron record (adult, teen, child, senior, etc.) Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>object</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>215</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Code</th>\n",
       "      <td>object</td>\n",
       "      <td>Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Month</th>\n",
       "      <td>object</td>\n",
       "      <td>Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>This column was not in original data dictionary</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <td>object</td>\n",
       "      <td>Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <td>object</td>\n",
       "      <td>This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "      <td>110310</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             Data Type  \\\n",
       "Column Name                              \n",
       "Patron Type Code                 int64   \n",
       "Patron Type Definition          object   \n",
       "Total Checkouts                  int64   \n",
       "Total Renewals                   int64   \n",
       "Age Range                       object   \n",
       "Home Library Code               object   \n",
       "Home Library Definition         object   \n",
       "Circulation Active Month        object   \n",
       "Circulation Active Year         object   \n",
       "Notice Preference Code          object   \n",
       "Notice Preference Definition    object   \n",
       "Provided Email Address            bool   \n",
       "Year Patron Registered           int64   \n",
       "Outside of County                 bool   \n",
       "Supervisor District            float64   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Code                                                                                                                                 Type of patron record (adult, teen, child, senior, etc.) Some blank.   \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Code                                         Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Circulation Active Month                                           Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Circulation Active Year                                            Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Notice Preference Code                                                                   This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                                                                Notes  \\\n",
       "Column Name                                                                                                                                                                                                                             \n",
       "Patron Type Code                                                                                                                                                                                                                  NaN   \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN   \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN   \n",
       "Total Renewals                                                                                                                                                                                                                    NaN   \n",
       "Age Range                                                                                                                                                                                                                         NaN   \n",
       "Home Library Code                                                                                                                                                                                                                 NaN   \n",
       "Home Library Definition                                                                                                                                                                                                           NaN   \n",
       "Circulation Active Month                                                                                                                                                              This column was not in original data dictionary   \n",
       "Circulation Active Year                                                                                                                                                                                                           NaN   \n",
       "Notice Preference Code                                                                                                                                                                                                            NaN   \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN   \n",
       "Provided Email Address                                                                                                                                                                                                            NaN   \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN   \n",
       "Outside of County                                                                                                                                                                                                                 NaN   \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...   \n",
       "\n",
       "                              Missing Values Count  \n",
       "Column Name                                         \n",
       "Patron Type Code                                 0  \n",
       "Patron Type Definition                           0  \n",
       "Total Checkouts                                  0  \n",
       "Total Renewals                                   0  \n",
       "Age Range                                      215  \n",
       "Home Library Code                               40  \n",
       "Home Library Definition                          0  \n",
       "Circulation Active Month                         0  \n",
       "Circulation Active Year                          0  \n",
       "Notice Preference Code                           0  \n",
       "Notice Preference Definition                     0  \n",
       "Provided Email Address                           0  \n",
       "Year Patron Registered                           0  \n",
       "Outside of County                                0  \n",
       "Supervisor District                         110310  "
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new['Missing Values Count'] = library.isna().sum()\n",
    "library_dd_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Can also do % of missing values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes</th>\n",
       "      <th>Missing Values Count</th>\n",
       "      <th>Missing Values %</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Code</th>\n",
       "      <td>int64</td>\n",
       "      <td>Type of patron record (adult, teen, child, senior, etc.) Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>object</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>215</td>\n",
       "      <td>0.000508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Code</th>\n",
       "      <td>object</td>\n",
       "      <td>Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>40</td>\n",
       "      <td>0.000094</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Month</th>\n",
       "      <td>object</td>\n",
       "      <td>Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>This column was not in original data dictionary</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <td>object</td>\n",
       "      <td>Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <td>object</td>\n",
       "      <td>This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "      <td>110310</td>\n",
       "      <td>0.260504</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             Data Type  \\\n",
       "Column Name                              \n",
       "Patron Type Code                 int64   \n",
       "Patron Type Definition          object   \n",
       "Total Checkouts                  int64   \n",
       "Total Renewals                   int64   \n",
       "Age Range                       object   \n",
       "Home Library Code               object   \n",
       "Home Library Definition         object   \n",
       "Circulation Active Month        object   \n",
       "Circulation Active Year         object   \n",
       "Notice Preference Code          object   \n",
       "Notice Preference Definition    object   \n",
       "Provided Email Address            bool   \n",
       "Year Patron Registered           int64   \n",
       "Outside of County                 bool   \n",
       "Supervisor District            float64   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Code                                                                                                                                 Type of patron record (adult, teen, child, senior, etc.) Some blank.   \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Code                                         Default value indicates the branch library where the patron was originally registered. Patrons can change this value if they change their preferred branch.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Circulation Active Month                                           Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Circulation Active Year                                            Month the patron last checked out library materials, or last logged into the library’s subscription databases from a computer outside the library.   \n",
       "Notice Preference Code                                                                   This field is used to indicate the patron’s preferred method of receiving library notices (email, print, phone). Some blank.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                                                                Notes  \\\n",
       "Column Name                                                                                                                                                                                                                             \n",
       "Patron Type Code                                                                                                                                                                                                                  NaN   \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN   \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN   \n",
       "Total Renewals                                                                                                                                                                                                                    NaN   \n",
       "Age Range                                                                                                                                                                                                                         NaN   \n",
       "Home Library Code                                                                                                                                                                                                                 NaN   \n",
       "Home Library Definition                                                                                                                                                                                                           NaN   \n",
       "Circulation Active Month                                                                                                                                                              This column was not in original data dictionary   \n",
       "Circulation Active Year                                                                                                                                                                                                           NaN   \n",
       "Notice Preference Code                                                                                                                                                                                                            NaN   \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN   \n",
       "Provided Email Address                                                                                                                                                                                                            NaN   \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN   \n",
       "Outside of County                                                                                                                                                                                                                 NaN   \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...   \n",
       "\n",
       "                              Missing Values Count  Missing Values %  \n",
       "Column Name                                                           \n",
       "Patron Type Code                                 0          0.000000  \n",
       "Patron Type Definition                           0          0.000000  \n",
       "Total Checkouts                                  0          0.000000  \n",
       "Total Renewals                                   0          0.000000  \n",
       "Age Range                                      215          0.000508  \n",
       "Home Library Code                               40          0.000094  \n",
       "Home Library Definition                          0          0.000000  \n",
       "Circulation Active Month                         0          0.000000  \n",
       "Circulation Active Year                          0          0.000000  \n",
       "Notice Preference Code                           0          0.000000  \n",
       "Notice Preference Definition                     0          0.000000  \n",
       "Provided Email Address                           0          0.000000  \n",
       "Year Patron Registered                           0          0.000000  \n",
       "Outside of County                                0          0.000000  \n",
       "Supervisor District                         110310          0.260504  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new['Missing Values %'] = library.isna().mean()\n",
    "library_dd_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Is the data tidy?\n",
    "This is an important question to ask towards the very beginning of a data analysis. Hadley Wickham is famous for instilling this core tennet.\n",
    "\n",
    "Tidy data is when:\n",
    "* Each variable forms a column\n",
    "* Each observation forms a row\n",
    "* Each observational unit forms a table\n",
    "\n",
    "## Check to see if our data is tidy\n",
    "Most data from relational databases will meet this criteria. This data is likely stored in a relational database and from the description we know that each row reprsents a single patron (an observation).\n",
    "\n",
    "Some columns appear to have duplicate information and we may not need them. Although, this isn't strictly mentioned in the three tidy principles, duplicate information won't add anything to our analysis.\n",
    "\n",
    "## Check for duplication of Patron Type Code amd Patron Type Description\n",
    "We can do a **two-way contingency table** to count the co-occurrences of each pair to determine if there is indeed a one-to-one mapping"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>ADULT</th>\n",
       "      <th>AT USER ADULT</th>\n",
       "      <th>AT USER JUVENILE</th>\n",
       "      <th>AT USER SENIOR</th>\n",
       "      <th>AT USER TEEN</th>\n",
       "      <th>AT USER WELCOME</th>\n",
       "      <th>BOOKS BY MAIL</th>\n",
       "      <th>DIGITAL ACCESS CARD</th>\n",
       "      <th>FRIENDS FOR LIFE</th>\n",
       "      <th>JUVENILE</th>\n",
       "      <th>RETIRED STAFF</th>\n",
       "      <th>SENIOR</th>\n",
       "      <th>SPECIAL</th>\n",
       "      <th>STAFF</th>\n",
       "      <th>TEACHER CARD</th>\n",
       "      <th>VISITOR</th>\n",
       "      <th>WELCOME</th>\n",
       "      <th>YOUNG ADULT</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Patron Type Code</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>272251</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>59208</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>28816</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>41619</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>14931</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>862</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>40</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>977</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>415</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>95</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1782</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1744</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>157</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>0</td>\n",
       "      <td>349</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>47</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>44</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>66</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>104</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>45</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Patron Type Definition   ADULT  AT USER ADULT  AT USER JUVENILE  \\\n",
       "Patron Type Code                                                  \n",
       "0                       272251              0                 0   \n",
       "1                            0              0                 0   \n",
       "2                            0              0                 0   \n",
       "3                            0              0                 0   \n",
       "4                            0              0                 0   \n",
       "5                            0              0                 0   \n",
       "8                            0              0                 0   \n",
       "9                            0              0                 0   \n",
       "10                           0              0                 0   \n",
       "12                           0              0                 0   \n",
       "15                           0              0                 0   \n",
       "16                           0              0                 0   \n",
       "55                           0              0                 0   \n",
       "100                          0            349                 0   \n",
       "101                          0              0                47   \n",
       "102                          0              0                 0   \n",
       "103                          0              0                 0   \n",
       "104                          0              0                 0   \n",
       "\n",
       "Patron Type Definition  AT USER SENIOR  AT USER TEEN  AT USER WELCOME  \\\n",
       "Patron Type Code                                                        \n",
       "0                                    0             0                0   \n",
       "1                                    0             0                0   \n",
       "2                                    0             0                0   \n",
       "3                                    0             0                0   \n",
       "4                                    0             0                0   \n",
       "5                                    0             0                0   \n",
       "8                                    0             0                0   \n",
       "9                                    0             0                0   \n",
       "10                                   0             0                0   \n",
       "12                                   0             0                0   \n",
       "15                                   0             0                0   \n",
       "16                                   0             0                0   \n",
       "55                                   0             0                0   \n",
       "100                                  0             0                0   \n",
       "101                                  0             0                0   \n",
       "102                                  0            44                0   \n",
       "103                                 66             0                0   \n",
       "104                                  0             0               45   \n",
       "\n",
       "Patron Type Definition  BOOKS BY MAIL  DIGITAL ACCESS CARD  FRIENDS FOR LIFE  \\\n",
       "Patron Type Code                                                               \n",
       "0                                   0                    0                 0   \n",
       "1                                   0                    0                 0   \n",
       "2                                   0                    0                 0   \n",
       "3                                   0                    0                 0   \n",
       "4                                   0                    0                 0   \n",
       "5                                   0                    0                 0   \n",
       "8                                   0                    0                40   \n",
       "9                                   0                    0                 0   \n",
       "10                                  0                    0                 0   \n",
       "12                                 95                    0                 0   \n",
       "15                                  0                    0                 0   \n",
       "16                                  0                 1744                 0   \n",
       "55                                  0                    0                 0   \n",
       "100                                 0                    0                 0   \n",
       "101                                 0                    0                 0   \n",
       "102                                 0                    0                 0   \n",
       "103                                 0                    0                 0   \n",
       "104                                 0                    0                 0   \n",
       "\n",
       "Patron Type Definition  JUVENILE  RETIRED STAFF  SENIOR  SPECIAL  STAFF  \\\n",
       "Patron Type Code                                                          \n",
       "0                              0              0       0        0      0   \n",
       "1                          59208              0       0        0      0   \n",
       "2                              0              0       0        0      0   \n",
       "3                              0              0   41619        0      0   \n",
       "4                              0              0       0        0      0   \n",
       "5                              0              0       0        0    862   \n",
       "8                              0              0       0        0      0   \n",
       "9                              0              0       0      977      0   \n",
       "10                             0              0       0        0      0   \n",
       "12                             0              0       0        0      0   \n",
       "15                             0              0       0        0      0   \n",
       "16                             0              0       0        0      0   \n",
       "55                             0            157       0        0      0   \n",
       "100                            0              0       0        0      0   \n",
       "101                            0              0       0        0      0   \n",
       "102                            0              0       0        0      0   \n",
       "103                            0              0       0        0      0   \n",
       "104                            0              0       0        0      0   \n",
       "\n",
       "Patron Type Definition  TEACHER CARD  VISITOR  WELCOME  YOUNG ADULT  \n",
       "Patron Type Code                                                     \n",
       "0                                  0        0        0            0  \n",
       "1                                  0        0        0            0  \n",
       "2                                  0        0        0        28816  \n",
       "3                                  0        0        0            0  \n",
       "4                                  0        0    14931            0  \n",
       "5                                  0        0        0            0  \n",
       "8                                  0        0        0            0  \n",
       "9                                  0        0        0            0  \n",
       "10                                 0      415        0            0  \n",
       "12                                 0        0        0            0  \n",
       "15                              1782        0        0            0  \n",
       "16                                 0        0        0            0  \n",
       "55                                 0        0        0            0  \n",
       "100                                0        0        0            0  \n",
       "101                                0        0        0            0  \n",
       "102                                0        0        0            0  \n",
       "103                                0        0        0            0  \n",
       "104                                0        0        0            0  "
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "patron_table = pd.crosstab(library['Patron Type Code'], library['Patron Type Definition'])\n",
    "patron_table"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ensuring a one to one relationship\n",
    "Let's see if the sum equals the maximum for all columns. If it does, then we can drop one of the columns."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Patron Type Definition\n",
       "ADULT                  True\n",
       "AT USER ADULT          True\n",
       "AT USER JUVENILE       True\n",
       "AT USER SENIOR         True\n",
       "AT USER TEEN           True\n",
       "AT USER WELCOME        True\n",
       "BOOKS BY MAIL          True\n",
       "DIGITAL ACCESS CARD    True\n",
       "FRIENDS FOR LIFE       True\n",
       "JUVENILE               True\n",
       "RETIRED STAFF          True\n",
       "SENIOR                 True\n",
       "SPECIAL                True\n",
       "STAFF                  True\n",
       "TEACHER CARD           True\n",
       "VISITOR                True\n",
       "WELCOME                True\n",
       "YOUNG ADULT            True\n",
       "dtype: bool"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "patron_table.sum() == patron_table.max()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Drop the Patron Type Code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>Total Checkouts</th>\n",
       "      <th>Total Renewals</th>\n",
       "      <th>Age Range</th>\n",
       "      <th>Home Library Code</th>\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Circulation Active Month</th>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>Provided Email Address</th>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <th>Outside of County</th>\n",
       "      <th>Supervisor District</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SENIOR</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "      <td>65 to 74 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>November</td>\n",
       "      <td>2012</td>\n",
       "      <td>z</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>55 to 59 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>October</td>\n",
       "      <td>2015</td>\n",
       "      <td>z</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>275</td>\n",
       "      <td>559</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>January</td>\n",
       "      <td>2015</td>\n",
       "      <td>z</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>73</td>\n",
       "      <td>38</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>M8</td>\n",
       "      <td>Mission Bay</td>\n",
       "      <td>February</td>\n",
       "      <td>2016</td>\n",
       "      <td>z</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>182</td>\n",
       "      <td>90</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>July</td>\n",
       "      <td>2016</td>\n",
       "      <td>z</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Patron Type Definition  Total Checkouts  Total Renewals       Age Range  \\\n",
       "0                 SENIOR               28              13  65 to 74 years   \n",
       "1                  ADULT               21              10  55 to 59 years   \n",
       "2                  ADULT              275             559  60 to 64 years   \n",
       "3                  ADULT               73              38  45 to 54 years   \n",
       "4                  ADULT              182              90  45 to 54 years   \n",
       "\n",
       "  Home Library Code Home Library Definition Circulation Active Month  \\\n",
       "0                 X            Main Library                 November   \n",
       "1                 X            Main Library                  October   \n",
       "2                 X            Main Library                  January   \n",
       "3                M8             Mission Bay                 February   \n",
       "4                 X            Main Library                     July   \n",
       "\n",
       "  Circulation Active Year Notice Preference Code Notice Preference Definition  \\\n",
       "0                    2012                      z                        email   \n",
       "1                    2015                      z                        email   \n",
       "2                    2015                      z                        email   \n",
       "3                    2016                      z                        email   \n",
       "4                    2016                      z                        email   \n",
       "\n",
       "   Provided Email Address  Year Patron Registered  Outside of County  \\\n",
       "0                    True                    2003               True   \n",
       "1                    True                    2003              False   \n",
       "2                    True                    2003               True   \n",
       "3                    True                    2003              False   \n",
       "4                    True                    2003              False   \n",
       "\n",
       "   Supervisor District  \n",
       "0                  NaN  \n",
       "1                  NaN  \n",
       "2                  NaN  \n",
       "3                  NaN  \n",
       "4                  NaN  "
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new = library.drop(columns='Patron Type Code')\n",
    "library_new.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Repeat for Notice Preference Code and Notice Preference Definition"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>email</th>\n",
       "      <th>none</th>\n",
       "      <th>phone</th>\n",
       "      <th>print</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Code</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>-</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>a</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>31336</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>p</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>68172</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>z</th>\n",
       "      <td>323937</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Notice Preference Definition   email  none  phone  print\n",
       "Notice Preference Code                                  \n",
       "-                                  0     3      0      0\n",
       "a                                  0     0      0  31336\n",
       "p                                  0     0  68172      0\n",
       "z                             323937     0      0      0"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.crosstab(library['Notice Preference Code'], library['Notice Preference Definition'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can easily determine that there is indeed a one-to-one mapping. Let's again drop the code and keep the definition."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>Total Checkouts</th>\n",
       "      <th>Total Renewals</th>\n",
       "      <th>Age Range</th>\n",
       "      <th>Home Library Code</th>\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Circulation Active Month</th>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>Provided Email Address</th>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <th>Outside of County</th>\n",
       "      <th>Supervisor District</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SENIOR</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "      <td>65 to 74 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>November</td>\n",
       "      <td>2012</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>55 to 59 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>October</td>\n",
       "      <td>2015</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>275</td>\n",
       "      <td>559</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>January</td>\n",
       "      <td>2015</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>73</td>\n",
       "      <td>38</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>M8</td>\n",
       "      <td>Mission Bay</td>\n",
       "      <td>February</td>\n",
       "      <td>2016</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>182</td>\n",
       "      <td>90</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>July</td>\n",
       "      <td>2016</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Patron Type Definition  Total Checkouts  Total Renewals       Age Range  \\\n",
       "0                 SENIOR               28              13  65 to 74 years   \n",
       "1                  ADULT               21              10  55 to 59 years   \n",
       "2                  ADULT              275             559  60 to 64 years   \n",
       "3                  ADULT               73              38  45 to 54 years   \n",
       "4                  ADULT              182              90  45 to 54 years   \n",
       "\n",
       "  Home Library Code Home Library Definition Circulation Active Month  \\\n",
       "0                 X            Main Library                 November   \n",
       "1                 X            Main Library                  October   \n",
       "2                 X            Main Library                  January   \n",
       "3                M8             Mission Bay                 February   \n",
       "4                 X            Main Library                     July   \n",
       "\n",
       "  Circulation Active Year Notice Preference Definition  \\\n",
       "0                    2012                        email   \n",
       "1                    2015                        email   \n",
       "2                    2015                        email   \n",
       "3                    2016                        email   \n",
       "4                    2016                        email   \n",
       "\n",
       "   Provided Email Address  Year Patron Registered  Outside of County  \\\n",
       "0                    True                    2003               True   \n",
       "1                    True                    2003              False   \n",
       "2                    True                    2003               True   \n",
       "3                    True                    2003              False   \n",
       "4                    True                    2003              False   \n",
       "\n",
       "   Supervisor District  \n",
       "0                  NaN  \n",
       "1                  NaN  \n",
       "2                  NaN  \n",
       "3                  NaN  \n",
       "4                  NaN  "
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new = library_new.drop(columns='Notice Preference Code')\n",
    "library_new.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Consolidating the dates\n",
    "**`Circulation Active Month`** and **`Circulation Active Year`** may be consolidated to a single field. We can always strip out the componenets later if we need them.\n",
    "\n",
    "Before we do this, let's take a look at the unique values/counts of each of these columns."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "July         91566\n",
       "None         67904\n",
       "June         40316\n",
       "May          31381\n",
       "April        25172\n",
       "March        23968\n",
       "August       22081\n",
       "December     20787\n",
       "January      20623\n",
       "September    20568\n",
       "February     19936\n",
       "October      19716\n",
       "November     19430\n",
       "Name: Circulation Active Month, dtype: int64"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library['Circulation Active Month'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2016    147901\n",
       "2015     79623\n",
       "None     67904\n",
       "2014     63502\n",
       "2013     43722\n",
       "2012      9571\n",
       "2011      3108\n",
       "2010      2975\n",
       "2009      1820\n",
       "2008      1244\n",
       "2007       710\n",
       "2006       567\n",
       "2005       498\n",
       "2004       297\n",
       "2003         6\n",
       "Name: Circulation Active Year, dtype: int64"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library['Circulation Active Year'].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Missing values?\n",
    "It appears there are missing values **'None'**, but our **`isna`** method didn't catch them. Let's look at the unique values to get a closer look."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['November', 'October', 'January', 'February', 'July', 'December',\n",
       "       'September', 'May', 'August', 'March', 'June', 'April', 'None'],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library['Circulation Active Month'].unique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Date Parsing\n",
    "There are multiple ways to construct dates with pandas. The **`to_datetime`** function is very flexible with what it accepts as a date string. Here, we simply concatenate the month and year and place a comma between the values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    November, 2012\n",
       "1     October, 2015\n",
       "2     January, 2015\n",
       "3    February, 2016\n",
       "4        July, 2016\n",
       "dtype: object"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dates = library['Circulation Active Month'] + ', ' + library['Circulation Active Year']\n",
    "dates.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0   2012-11-01\n",
       "1   2015-10-01\n",
       "2   2015-01-01\n",
       "3   2016-02-01\n",
       "4   2016-07-01\n",
       "dtype: datetime64[ns]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.to_datetime(dates.head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "circulation_ad = pd.to_datetime(dates, errors='coerce')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Use the **`insert`** method to put in new column in a specific place"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "loc = library_new.columns.get_loc('Circulation Active Month')\n",
    "loc"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This happens **inplace**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "library_new.insert(loc, 'Circulation Active Date', circulation_ad)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>Total Checkouts</th>\n",
       "      <th>Total Renewals</th>\n",
       "      <th>Age Range</th>\n",
       "      <th>Home Library Code</th>\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <th>Circulation Active Month</th>\n",
       "      <th>Circulation Active Year</th>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>Provided Email Address</th>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <th>Outside of County</th>\n",
       "      <th>Supervisor District</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SENIOR</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "      <td>65 to 74 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2012-11-01</td>\n",
       "      <td>November</td>\n",
       "      <td>2012</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>55 to 59 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-10-01</td>\n",
       "      <td>October</td>\n",
       "      <td>2015</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>275</td>\n",
       "      <td>559</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>January</td>\n",
       "      <td>2015</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>73</td>\n",
       "      <td>38</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>M8</td>\n",
       "      <td>Mission Bay</td>\n",
       "      <td>2016-02-01</td>\n",
       "      <td>February</td>\n",
       "      <td>2016</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>182</td>\n",
       "      <td>90</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>July</td>\n",
       "      <td>2016</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Patron Type Definition  Total Checkouts  Total Renewals       Age Range  \\\n",
       "0                 SENIOR               28              13  65 to 74 years   \n",
       "1                  ADULT               21              10  55 to 59 years   \n",
       "2                  ADULT              275             559  60 to 64 years   \n",
       "3                  ADULT               73              38  45 to 54 years   \n",
       "4                  ADULT              182              90  45 to 54 years   \n",
       "\n",
       "  Home Library Code Home Library Definition Circulation Active Date  \\\n",
       "0                 X            Main Library              2012-11-01   \n",
       "1                 X            Main Library              2015-10-01   \n",
       "2                 X            Main Library              2015-01-01   \n",
       "3                M8             Mission Bay              2016-02-01   \n",
       "4                 X            Main Library              2016-07-01   \n",
       "\n",
       "  Circulation Active Month Circulation Active Year  \\\n",
       "0                 November                    2012   \n",
       "1                  October                    2015   \n",
       "2                  January                    2015   \n",
       "3                 February                    2016   \n",
       "4                     July                    2016   \n",
       "\n",
       "  Notice Preference Definition  Provided Email Address  \\\n",
       "0                        email                    True   \n",
       "1                        email                    True   \n",
       "2                        email                    True   \n",
       "3                        email                    True   \n",
       "4                        email                    True   \n",
       "\n",
       "   Year Patron Registered  Outside of County  Supervisor District  \n",
       "0                    2003               True                  NaN  \n",
       "1                    2003              False                  NaN  \n",
       "2                    2003               True                  NaN  \n",
       "3                    2003              False                  NaN  \n",
       "4                    2003              False                  NaN  "
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "67904"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "circulation_ad.isna().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Drop the old Circulation columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>Total Checkouts</th>\n",
       "      <th>Total Renewals</th>\n",
       "      <th>Age Range</th>\n",
       "      <th>Home Library Code</th>\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>Provided Email Address</th>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <th>Outside of County</th>\n",
       "      <th>Supervisor District</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SENIOR</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "      <td>65 to 74 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2012-11-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>55 to 59 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-10-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>275</td>\n",
       "      <td>559</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>73</td>\n",
       "      <td>38</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>M8</td>\n",
       "      <td>Mission Bay</td>\n",
       "      <td>2016-02-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>182</td>\n",
       "      <td>90</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>X</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Patron Type Definition  Total Checkouts  Total Renewals       Age Range  \\\n",
       "0                 SENIOR               28              13  65 to 74 years   \n",
       "1                  ADULT               21              10  55 to 59 years   \n",
       "2                  ADULT              275             559  60 to 64 years   \n",
       "3                  ADULT               73              38  45 to 54 years   \n",
       "4                  ADULT              182              90  45 to 54 years   \n",
       "\n",
       "  Home Library Code Home Library Definition Circulation Active Date  \\\n",
       "0                 X            Main Library              2012-11-01   \n",
       "1                 X            Main Library              2015-10-01   \n",
       "2                 X            Main Library              2015-01-01   \n",
       "3                M8             Mission Bay              2016-02-01   \n",
       "4                 X            Main Library              2016-07-01   \n",
       "\n",
       "  Notice Preference Definition  Provided Email Address  \\\n",
       "0                        email                    True   \n",
       "1                        email                    True   \n",
       "2                        email                    True   \n",
       "3                        email                    True   \n",
       "4                        email                    True   \n",
       "\n",
       "   Year Patron Registered  Outside of County  Supervisor District  \n",
       "0                    2003               True                  NaN  \n",
       "1                    2003              False                  NaN  \n",
       "2                    2003               True                  NaN  \n",
       "3                    2003              False                  NaN  \n",
       "4                    2003              False                  NaN  "
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new = library_new.drop(columns=['Circulation Active Year', 'Circulation Active Month'])\n",
    "library_new.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## One more set of columns - Home Library"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Anza</th>\n",
       "      <th>Bayview/Linda Brooks-Burton</th>\n",
       "      <th>Bernal Heights</th>\n",
       "      <th>Branch Bookmobile (Excelsior)</th>\n",
       "      <th>Branch Bookmobile (Marina)</th>\n",
       "      <th>Branch Bookmobile (Sunset)</th>\n",
       "      <th>Branch Bookmobile (West Portal)</th>\n",
       "      <th>Children's Bookmobile</th>\n",
       "      <th>Chinatown</th>\n",
       "      <th>Eureka Valley/Harvey Milk Memorial</th>\n",
       "      <th>...</th>\n",
       "      <th>Parkside</th>\n",
       "      <th>Portola</th>\n",
       "      <th>Potrero</th>\n",
       "      <th>Presidio</th>\n",
       "      <th>Richmond</th>\n",
       "      <th>Sunset</th>\n",
       "      <th>Unknown</th>\n",
       "      <th>Visitacion Valley</th>\n",
       "      <th>West Portal</th>\n",
       "      <th>Western Addition</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Code</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A5</th>\n",
       "      <td>7183</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>AQUIS</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B2</th>\n",
       "      <td>0</td>\n",
       "      <td>8417</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B2AAA</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B2AZZ</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B4</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>9630</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B4AAA</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C2</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>17140</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C2J</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>32</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>E7</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8708</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "Home Library Definition  Anza  Bayview/Linda Brooks-Burton  Bernal Heights  \\\n",
       "Home Library Code                                                            \n",
       "A5                       7183                            0               0   \n",
       "AQUIS                       0                            0               0   \n",
       "B2                          0                         8417               0   \n",
       "B2AAA                       0                            0               0   \n",
       "B2AZZ                       0                            0               0   \n",
       "B4                          0                            0            9630   \n",
       "B4AAA                       0                            0               0   \n",
       "C2                          0                            0               0   \n",
       "C2J                         0                            0               0   \n",
       "E7                          0                            0               0   \n",
       "\n",
       "Home Library Definition  Branch Bookmobile (Excelsior)  \\\n",
       "Home Library Code                                        \n",
       "A5                                                   0   \n",
       "AQUIS                                                0   \n",
       "B2                                                   0   \n",
       "B2AAA                                                0   \n",
       "B2AZZ                                                0   \n",
       "B4                                                   0   \n",
       "B4AAA                                                0   \n",
       "C2                                                   0   \n",
       "C2J                                                  0   \n",
       "E7                                                   0   \n",
       "\n",
       "Home Library Definition  Branch Bookmobile (Marina)  \\\n",
       "Home Library Code                                     \n",
       "A5                                                0   \n",
       "AQUIS                                             0   \n",
       "B2                                                0   \n",
       "B2AAA                                             0   \n",
       "B2AZZ                                             0   \n",
       "B4                                                0   \n",
       "B4AAA                                             0   \n",
       "C2                                                0   \n",
       "C2J                                               0   \n",
       "E7                                                0   \n",
       "\n",
       "Home Library Definition  Branch Bookmobile (Sunset)  \\\n",
       "Home Library Code                                     \n",
       "A5                                                0   \n",
       "AQUIS                                             0   \n",
       "B2                                                0   \n",
       "B2AAA                                             0   \n",
       "B2AZZ                                             0   \n",
       "B4                                                0   \n",
       "B4AAA                                             0   \n",
       "C2                                                0   \n",
       "C2J                                               0   \n",
       "E7                                                0   \n",
       "\n",
       "Home Library Definition  Branch Bookmobile (West Portal)  \\\n",
       "Home Library Code                                          \n",
       "A5                                                     0   \n",
       "AQUIS                                                  0   \n",
       "B2                                                     0   \n",
       "B2AAA                                                  0   \n",
       "B2AZZ                                                  0   \n",
       "B4                                                     0   \n",
       "B4AAA                                                  0   \n",
       "C2                                                     0   \n",
       "C2J                                                    0   \n",
       "E7                                                     0   \n",
       "\n",
       "Home Library Definition  Children's Bookmobile  Chinatown  \\\n",
       "Home Library Code                                           \n",
       "A5                                           0          0   \n",
       "AQUIS                                        0          0   \n",
       "B2                                           0          0   \n",
       "B2AAA                                        0          0   \n",
       "B2AZZ                                        0          0   \n",
       "B4                                           0          0   \n",
       "B4AAA                                        0          0   \n",
       "C2                                           0      17140   \n",
       "C2J                                          0          0   \n",
       "E7                                           0          0   \n",
       "\n",
       "Home Library Definition  Eureka Valley/Harvey Milk Memorial        ...         \\\n",
       "Home Library Code                                                  ...          \n",
       "A5                                                        0        ...          \n",
       "AQUIS                                                     0        ...          \n",
       "B2                                                        0        ...          \n",
       "B2AAA                                                     0        ...          \n",
       "B2AZZ                                                     0        ...          \n",
       "B4                                                        0        ...          \n",
       "B4AAA                                                     0        ...          \n",
       "C2                                                        0        ...          \n",
       "C2J                                                       0        ...          \n",
       "E7                                                     8708        ...          \n",
       "\n",
       "Home Library Definition  Parkside  Portola  Potrero  Presidio  Richmond  \\\n",
       "Home Library Code                                                         \n",
       "A5                              0        0        0         0         0   \n",
       "AQUIS                           0        0        0         0         0   \n",
       "B2                              0        0        0         0         0   \n",
       "B2AAA                           0        0        0         0         0   \n",
       "B2AZZ                           0        0        0         0         0   \n",
       "B4                              0        0        0         0         0   \n",
       "B4AAA                           0        0        0         0         0   \n",
       "C2                              0        0        0         0         0   \n",
       "C2J                             0        0        0         0         0   \n",
       "E7                              0        0        0         0         0   \n",
       "\n",
       "Home Library Definition  Sunset  Unknown  Visitacion Valley  West Portal  \\\n",
       "Home Library Code                                                          \n",
       "A5                            0        0                  0            0   \n",
       "AQUIS                         0        1                  0            0   \n",
       "B2                            0        0                  0            0   \n",
       "B2AAA                         0        6                  0            0   \n",
       "B2AZZ                         0        1                  0            0   \n",
       "B4                            0        0                  0            0   \n",
       "B4AAA                         0        2                  0            0   \n",
       "C2                            0        0                  0            0   \n",
       "C2J                           0       32                  0            0   \n",
       "E7                            0        0                  0            0   \n",
       "\n",
       "Home Library Definition  Western Addition  \n",
       "Home Library Code                          \n",
       "A5                                      0  \n",
       "AQUIS                                   0  \n",
       "B2                                      0  \n",
       "B2AAA                                   0  \n",
       "B2AZZ                                   0  \n",
       "B4                                      0  \n",
       "B4AAA                                   0  \n",
       "C2                                      0  \n",
       "C2J                                     0  \n",
       "E7                                      0  \n",
       "\n",
       "[10 rows x 35 columns]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "home_library_codes = pd.crosstab(library_new['Home Library Code'], library_new['Home Library Definition'])\n",
    "home_library_codes.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Home Library Definition\n",
       "Anza                                   True\n",
       "Bayview/Linda Brooks-Burton            True\n",
       "Bernal Heights                         True\n",
       "Branch Bookmobile (Excelsior)          True\n",
       "Branch Bookmobile (Marina)             True\n",
       "Branch Bookmobile (Sunset)             True\n",
       "Branch Bookmobile (West Portal)        True\n",
       "Children's Bookmobile                  True\n",
       "Chinatown                              True\n",
       "Eureka Valley/Harvey Milk Memorial     True\n",
       "Excelsior                              True\n",
       "Glen Park                              True\n",
       "Golden Gate Valley                     True\n",
       "Ingleside                              True\n",
       "Library on Wheels                      True\n",
       "Main Library                           True\n",
       "Marina                                 True\n",
       "Merced                                 True\n",
       "Mission                                True\n",
       "Mission Bay                            True\n",
       "Noe Valley/Sally Brunn                 True\n",
       "North Beach                            True\n",
       "Ocean View                             True\n",
       "Ortega                                 True\n",
       "Park                                   True\n",
       "Parkside                               True\n",
       "Portola                                True\n",
       "Potrero                                True\n",
       "Presidio                               True\n",
       "Richmond                               True\n",
       "Sunset                                 True\n",
       "Unknown                               False\n",
       "Visitacion Valley                      True\n",
       "West Portal                            True\n",
       "Western Addition                       True\n",
       "dtype: bool"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "home_library_codes.sum() == home_library_codes.max()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Not quite a one-to-one mapping \n",
    "Some codes have an **unknown description** If we drop the code column, we would be losing some information. If most of the unknowns belong to a single code, we might be able to drop it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1458, 754)"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "home_library_codes['Unknown'].sum(), home_library_codes['Unknown'].max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "45"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "home_library_codes['Unknown'].ne(0).sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are 45 library codes that have atleast one unknown value. So, there could be value in keeping this column but for now, we will drop it to simplify our lives and make a note of this."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>Total Checkouts</th>\n",
       "      <th>Total Renewals</th>\n",
       "      <th>Age Range</th>\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>Provided Email Address</th>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <th>Outside of County</th>\n",
       "      <th>Supervisor District</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SENIOR</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "      <td>65 to 74 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2012-11-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>55 to 59 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-10-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>275</td>\n",
       "      <td>559</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>73</td>\n",
       "      <td>38</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Mission Bay</td>\n",
       "      <td>2016-02-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>182</td>\n",
       "      <td>90</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Patron Type Definition  Total Checkouts  Total Renewals       Age Range  \\\n",
       "0                 SENIOR               28              13  65 to 74 years   \n",
       "1                  ADULT               21              10  55 to 59 years   \n",
       "2                  ADULT              275             559  60 to 64 years   \n",
       "3                  ADULT               73              38  45 to 54 years   \n",
       "4                  ADULT              182              90  45 to 54 years   \n",
       "\n",
       "  Home Library Definition Circulation Active Date  \\\n",
       "0            Main Library              2012-11-01   \n",
       "1            Main Library              2015-10-01   \n",
       "2            Main Library              2015-01-01   \n",
       "3             Mission Bay              2016-02-01   \n",
       "4            Main Library              2016-07-01   \n",
       "\n",
       "  Notice Preference Definition  Provided Email Address  \\\n",
       "0                        email                    True   \n",
       "1                        email                    True   \n",
       "2                        email                    True   \n",
       "3                        email                    True   \n",
       "4                        email                    True   \n",
       "\n",
       "   Year Patron Registered  Outside of County  Supervisor District  \n",
       "0                    2003               True                  NaN  \n",
       "1                    2003              False                  NaN  \n",
       "2                    2003               True                  NaN  \n",
       "3                    2003              False                  NaN  \n",
       "4                    2003              False                  NaN  "
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new = library_new.drop(columns='Home Library Code')\n",
    "library_new.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Clean-up data dictionary\n",
    "We have dropped several columns from our data. Let's drop them from the index of our data dictionary."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes</th>\n",
       "      <th>Missing Values Count</th>\n",
       "      <th>Missing Values %</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>object</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>215</td>\n",
       "      <td>0.000508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "      <td>110310</td>\n",
       "      <td>0.260504</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             Data Type  \\\n",
       "Column Name                              \n",
       "Patron Type Definition          object   \n",
       "Total Checkouts                  int64   \n",
       "Total Renewals                   int64   \n",
       "Age Range                       object   \n",
       "Home Library Definition         object   \n",
       "Notice Preference Definition    object   \n",
       "Provided Email Address            bool   \n",
       "Year Patron Registered           int64   \n",
       "Outside of County                 bool   \n",
       "Supervisor District            float64   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                                                                Notes  \\\n",
       "Column Name                                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN   \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN   \n",
       "Total Renewals                                                                                                                                                                                                                    NaN   \n",
       "Age Range                                                                                                                                                                                                                         NaN   \n",
       "Home Library Definition                                                                                                                                                                                                           NaN   \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN   \n",
       "Provided Email Address                                                                                                                                                                                                            NaN   \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN   \n",
       "Outside of County                                                                                                                                                                                                                 NaN   \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...   \n",
       "\n",
       "                              Missing Values Count  Missing Values %  \n",
       "Column Name                                                           \n",
       "Patron Type Definition                           0          0.000000  \n",
       "Total Checkouts                                  0          0.000000  \n",
       "Total Renewals                                   0          0.000000  \n",
       "Age Range                                      215          0.000508  \n",
       "Home Library Definition                          0          0.000000  \n",
       "Notice Preference Definition                     0          0.000000  \n",
       "Provided Email Address                           0          0.000000  \n",
       "Year Patron Registered                           0          0.000000  \n",
       "Outside of County                                0          0.000000  \n",
       "Supervisor District                         110310          0.260504  "
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new= library_dd_new.drop(index=['Patron Type Code', 'Home Library Code', \n",
    "                                           'Circulation Active Month', 'Circulation Active Year', \n",
    "                                           'Notice Preference Code'])\n",
    "library_dd_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# We also added a column to our data dictonary\n",
    "Let's append it to the bottom (and correct its placement later)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "dtype = library_new.dtypes['Circulation Active Date']\n",
    "description = \"Date the patron last checked out library materials, or last logged into the library's \" \\\n",
    "              \"subscription databases from a computer outside the library. \"\n",
    "count_na = library_new['Circulation Active Date'].isna().sum()\n",
    "pct_na = library_new['Circulation Active Date'].isna().mean()\n",
    "note = 'This column replaced both Circulation Active Month/Year'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "library_dd_new.loc['Circulation Active Date'] = [dtype, description, note, count_na, pct_na]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes</th>\n",
       "      <th>Missing Values Count</th>\n",
       "      <th>Missing Values %</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>object</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>215</td>\n",
       "      <td>0.000508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "      <td>110310</td>\n",
       "      <td>0.260504</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <td>datetime64[ns]</td>\n",
       "      <td>Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.</td>\n",
       "      <td>This column replaced both Circulation Active Month/Year</td>\n",
       "      <td>67904</td>\n",
       "      <td>0.160360</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   Data Type  \\\n",
       "Column Name                                    \n",
       "Patron Type Definition                object   \n",
       "Total Checkouts                        int64   \n",
       "Total Renewals                         int64   \n",
       "Age Range                             object   \n",
       "Home Library Definition               object   \n",
       "Notice Preference Definition          object   \n",
       "Provided Email Address                  bool   \n",
       "Year Patron Registered                 int64   \n",
       "Outside of County                       bool   \n",
       "Supervisor District                  float64   \n",
       "Circulation Active Date       datetime64[ns]   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "Circulation Active Date                                            Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.    \n",
       "\n",
       "                                                                                                                                                                                                                                Notes  \\\n",
       "Column Name                                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN   \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN   \n",
       "Total Renewals                                                                                                                                                                                                                    NaN   \n",
       "Age Range                                                                                                                                                                                                                         NaN   \n",
       "Home Library Definition                                                                                                                                                                                                           NaN   \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN   \n",
       "Provided Email Address                                                                                                                                                                                                            NaN   \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN   \n",
       "Outside of County                                                                                                                                                                                                                 NaN   \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...   \n",
       "Circulation Active Date                                                                                                                                                       This column replaced both Circulation Active Month/Year   \n",
       "\n",
       "                              Missing Values Count  Missing Values %  \n",
       "Column Name                                                           \n",
       "Patron Type Definition                           0          0.000000  \n",
       "Total Checkouts                                  0          0.000000  \n",
       "Total Renewals                                   0          0.000000  \n",
       "Age Range                                      215          0.000508  \n",
       "Home Library Definition                          0          0.000000  \n",
       "Notice Preference Definition                     0          0.000000  \n",
       "Provided Email Address                           0          0.000000  \n",
       "Year Patron Registered                           0          0.000000  \n",
       "Outside of County                                0          0.000000  \n",
       "Supervisor District                         110310          0.260504  \n",
       "Circulation Active Date                      67904          0.160360  "
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Add notes for **Code** columns that were dropped"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "library_dd_new.loc['Patron Type Definition', 'Note'] = 'Patron Code had 1-1 mapping and was subsequently dropped'\n",
    "library_dd_new.loc['Home Library Definition', 'Note'] = 'Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped'\n",
    "library_dd_new.loc['Notice Preference Definition', 'Note'] = 'Patron Code had 1-1 mapping and was subsequently dropped'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes</th>\n",
       "      <th>Missing Values Count</th>\n",
       "      <th>Missing Values %</th>\n",
       "      <th>Note</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Patron Code had 1-1 mapping and was subsequently dropped</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>object</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>215</td>\n",
       "      <td>0.000508</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Patron Code had 1-1 mapping and was subsequently dropped</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "      <td>110310</td>\n",
       "      <td>0.260504</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <td>datetime64[ns]</td>\n",
       "      <td>Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.</td>\n",
       "      <td>This column replaced both Circulation Active Month/Year</td>\n",
       "      <td>67904</td>\n",
       "      <td>0.160360</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   Data Type  \\\n",
       "Column Name                                    \n",
       "Patron Type Definition                object   \n",
       "Total Checkouts                        int64   \n",
       "Total Renewals                         int64   \n",
       "Age Range                             object   \n",
       "Home Library Definition               object   \n",
       "Notice Preference Definition          object   \n",
       "Provided Email Address                  bool   \n",
       "Year Patron Registered                 int64   \n",
       "Outside of County                       bool   \n",
       "Supervisor District                  float64   \n",
       "Circulation Active Date       datetime64[ns]   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "Circulation Active Date                                            Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.    \n",
       "\n",
       "                                                                                                                                                                                                                                Notes  \\\n",
       "Column Name                                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN   \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN   \n",
       "Total Renewals                                                                                                                                                                                                                    NaN   \n",
       "Age Range                                                                                                                                                                                                                         NaN   \n",
       "Home Library Definition                                                                                                                                                                                                           NaN   \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN   \n",
       "Provided Email Address                                                                                                                                                                                                            NaN   \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN   \n",
       "Outside of County                                                                                                                                                                                                                 NaN   \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...   \n",
       "Circulation Active Date                                                                                                                                                       This column replaced both Circulation Active Month/Year   \n",
       "\n",
       "                              Missing Values Count  Missing Values %  \\\n",
       "Column Name                                                            \n",
       "Patron Type Definition                           0          0.000000   \n",
       "Total Checkouts                                  0          0.000000   \n",
       "Total Renewals                                   0          0.000000   \n",
       "Age Range                                      215          0.000508   \n",
       "Home Library Definition                          0          0.000000   \n",
       "Notice Preference Definition                     0          0.000000   \n",
       "Provided Email Address                           0          0.000000   \n",
       "Year Patron Registered                           0          0.000000   \n",
       "Outside of County                                0          0.000000   \n",
       "Supervisor District                         110310          0.260504   \n",
       "Circulation Active Date                      67904          0.160360   \n",
       "\n",
       "                                                                                                           Note  \n",
       "Column Name                                                                                                      \n",
       "Patron Type Definition                                 Patron Code had 1-1 mapping and was subsequently dropped  \n",
       "Total Checkouts                                                                                             NaN  \n",
       "Total Renewals                                                                                              NaN  \n",
       "Age Range                                                                                                   NaN  \n",
       "Home Library Definition       Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped  \n",
       "Notice Preference Definition                           Patron Code had 1-1 mapping and was subsequently dropped  \n",
       "Provided Email Address                                                                                      NaN  \n",
       "Year Patron Registered                                                                                      NaN  \n",
       "Outside of County                                                                                           NaN  \n",
       "Supervisor District                                                                                         NaN  \n",
       "Circulation Active Date                                                                                     NaN  "
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Rearrange Columns\n",
    "Initial column order is not something set in stone. You can change the order to better suit your needs. Typically, categorical variables are placed before continuous variables, but you can create an arrangement that helps you analyze the data better."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>Total Checkouts</th>\n",
       "      <th>Total Renewals</th>\n",
       "      <th>Age Range</th>\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>Provided Email Address</th>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <th>Outside of County</th>\n",
       "      <th>Supervisor District</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SENIOR</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "      <td>65 to 74 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2012-11-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>55 to 59 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-10-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>275</td>\n",
       "      <td>559</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>73</td>\n",
       "      <td>38</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Mission Bay</td>\n",
       "      <td>2016-02-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>182</td>\n",
       "      <td>90</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Patron Type Definition  Total Checkouts  Total Renewals       Age Range  \\\n",
       "0                 SENIOR               28              13  65 to 74 years   \n",
       "1                  ADULT               21              10  55 to 59 years   \n",
       "2                  ADULT              275             559  60 to 64 years   \n",
       "3                  ADULT               73              38  45 to 54 years   \n",
       "4                  ADULT              182              90  45 to 54 years   \n",
       "\n",
       "  Home Library Definition Circulation Active Date  \\\n",
       "0            Main Library              2012-11-01   \n",
       "1            Main Library              2015-10-01   \n",
       "2            Main Library              2015-01-01   \n",
       "3             Mission Bay              2016-02-01   \n",
       "4            Main Library              2016-07-01   \n",
       "\n",
       "  Notice Preference Definition  Provided Email Address  \\\n",
       "0                        email                    True   \n",
       "1                        email                    True   \n",
       "2                        email                    True   \n",
       "3                        email                    True   \n",
       "4                        email                    True   \n",
       "\n",
       "   Year Patron Registered  Outside of County  Supervisor District  \n",
       "0                    2003               True                  NaN  \n",
       "1                    2003              False                  NaN  \n",
       "2                    2003               True                  NaN  \n",
       "3                    2003              False                  NaN  \n",
       "4                    2003              False                  NaN  "
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It helps to print out the columns:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['Patron Type Definition', 'Total Checkouts', 'Total Renewals',\n",
       "       'Age Range', 'Home Library Definition', 'Circulation Active Date',\n",
       "       'Notice Preference Definition', 'Provided Email Address',\n",
       "       'Year Patron Registered', 'Outside of County', 'Supervisor District'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_col_order = ['Patron Type Definition', 'Age Range', 'Home Library Definition', \n",
    "                 'Circulation Active Date', 'Total Checkouts', 'Total Renewals',\n",
    "                 'Notice Preference Definition', 'Provided Email Address',\n",
    "                 'Year Patron Registered', 'Outside of County', 'Supervisor District']\n",
    "len(new_col_order) == len(library_new.columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set(new_col_order) == set(library_new.columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>Age Range</th>\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <th>Total Checkouts</th>\n",
       "      <th>Total Renewals</th>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>Provided Email Address</th>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <th>Outside of County</th>\n",
       "      <th>Supervisor District</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SENIOR</td>\n",
       "      <td>65 to 74 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2012-11-01</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>55 to 59 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-10-01</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>275</td>\n",
       "      <td>559</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Mission Bay</td>\n",
       "      <td>2016-02-01</td>\n",
       "      <td>73</td>\n",
       "      <td>38</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>182</td>\n",
       "      <td>90</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Patron Type Definition       Age Range Home Library Definition  \\\n",
       "0                 SENIOR  65 to 74 years            Main Library   \n",
       "1                  ADULT  55 to 59 years            Main Library   \n",
       "2                  ADULT  60 to 64 years            Main Library   \n",
       "3                  ADULT  45 to 54 years             Mission Bay   \n",
       "4                  ADULT  45 to 54 years            Main Library   \n",
       "\n",
       "  Circulation Active Date  Total Checkouts  Total Renewals  \\\n",
       "0              2012-11-01               28              13   \n",
       "1              2015-10-01               21              10   \n",
       "2              2015-01-01              275             559   \n",
       "3              2016-02-01               73              38   \n",
       "4              2016-07-01              182              90   \n",
       "\n",
       "  Notice Preference Definition  Provided Email Address  \\\n",
       "0                        email                    True   \n",
       "1                        email                    True   \n",
       "2                        email                    True   \n",
       "3                        email                    True   \n",
       "4                        email                    True   \n",
       "\n",
       "   Year Patron Registered  Outside of County  Supervisor District  \n",
       "0                    2003               True                  NaN  \n",
       "1                    2003              False                  NaN  \n",
       "2                    2003               True                  NaN  \n",
       "3                    2003              False                  NaN  \n",
       "4                    2003              False                  NaN  "
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new = library_new[new_col_order]\n",
    "library_new.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Use these columns to rearrange the data dictionary as well"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes</th>\n",
       "      <th>Missing Values Count</th>\n",
       "      <th>Missing Values %</th>\n",
       "      <th>Note</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Patron Code had 1-1 mapping and was subsequently dropped</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>object</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>215</td>\n",
       "      <td>0.000508</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <td>datetime64[ns]</td>\n",
       "      <td>Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.</td>\n",
       "      <td>This column replaced both Circulation Active Month/Year</td>\n",
       "      <td>67904</td>\n",
       "      <td>0.160360</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Patron Code had 1-1 mapping and was subsequently dropped</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "      <td>110310</td>\n",
       "      <td>0.260504</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   Data Type  \\\n",
       "Column Name                                    \n",
       "Patron Type Definition                object   \n",
       "Age Range                             object   \n",
       "Home Library Definition               object   \n",
       "Circulation Active Date       datetime64[ns]   \n",
       "Total Checkouts                        int64   \n",
       "Total Renewals                         int64   \n",
       "Notice Preference Definition          object   \n",
       "Provided Email Address                  bool   \n",
       "Year Patron Registered                 int64   \n",
       "Outside of County                       bool   \n",
       "Supervisor District                  float64   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Circulation Active Date                                            Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.    \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "\n",
       "                                                                                                                                                                                                                                Notes  \\\n",
       "Column Name                                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN   \n",
       "Age Range                                                                                                                                                                                                                         NaN   \n",
       "Home Library Definition                                                                                                                                                                                                           NaN   \n",
       "Circulation Active Date                                                                                                                                                       This column replaced both Circulation Active Month/Year   \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN   \n",
       "Total Renewals                                                                                                                                                                                                                    NaN   \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN   \n",
       "Provided Email Address                                                                                                                                                                                                            NaN   \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN   \n",
       "Outside of County                                                                                                                                                                                                                 NaN   \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...   \n",
       "\n",
       "                              Missing Values Count  Missing Values %  \\\n",
       "Column Name                                                            \n",
       "Patron Type Definition                           0          0.000000   \n",
       "Age Range                                      215          0.000508   \n",
       "Home Library Definition                          0          0.000000   \n",
       "Circulation Active Date                      67904          0.160360   \n",
       "Total Checkouts                                  0          0.000000   \n",
       "Total Renewals                                   0          0.000000   \n",
       "Notice Preference Definition                     0          0.000000   \n",
       "Provided Email Address                           0          0.000000   \n",
       "Year Patron Registered                           0          0.000000   \n",
       "Outside of County                                0          0.000000   \n",
       "Supervisor District                         110310          0.260504   \n",
       "\n",
       "                                                                                                           Note  \n",
       "Column Name                                                                                                      \n",
       "Patron Type Definition                                 Patron Code had 1-1 mapping and was subsequently dropped  \n",
       "Age Range                                                                                                   NaN  \n",
       "Home Library Definition       Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped  \n",
       "Circulation Active Date                                                                                     NaN  \n",
       "Total Checkouts                                                                                             NaN  \n",
       "Total Renewals                                                                                              NaN  \n",
       "Notice Preference Definition                           Patron Code had 1-1 mapping and was subsequently dropped  \n",
       "Provided Email Address                                                                                      NaN  \n",
       "Year Patron Registered                                                                                      NaN  \n",
       "Outside of County                                                                                           NaN  \n",
       "Supervisor District                                                                                         NaN  "
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new.loc[new_col_order]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Tidier data\n",
    "Data should now be easier to do analysis. There are other datasets that take quite a lot more work."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Univariate Descriptive Statistics\n",
    "I generally recommend by starting with simple one-dimensional data analysis once you have tidy data. The chart in the checklist sheet can help you determine what graphical/non-graphical approaches you can take based on the type of data."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Using the describe method\n",
    "The describe method is good for getting the five-number summary (min, max, median, first/third quartiles) for continuous data. It also gives the number of unique values and most common value for the categorical values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>count</th>\n",
       "      <th>unique</th>\n",
       "      <th>top</th>\n",
       "      <th>freq</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>423448</td>\n",
       "      <td>18</td>\n",
       "      <td>ADULT</td>\n",
       "      <td>272251</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>423233</td>\n",
       "      <td>10</td>\n",
       "      <td>25 to 34 years</td>\n",
       "      <td>91083</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>423448</td>\n",
       "      <td>35</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>124814</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>423448</td>\n",
       "      <td>4</td>\n",
       "      <td>email</td>\n",
       "      <td>323937</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               count unique             top    freq\n",
       "Patron Type Definition        423448     18           ADULT  272251\n",
       "Age Range                     423233     10  25 to 34 years   91083\n",
       "Home Library Definition       423448     35    Main Library  124814\n",
       "Notice Preference Definition  423448      4           email  323937"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new.describe(include='O').T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's add the number of unique values to our data dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Patron Type Definition            18\n",
       "Age Range                         10\n",
       "Home Library Definition           35\n",
       "Circulation Active Date          152\n",
       "Total Checkouts                 4274\n",
       "Total Renewals                  2738\n",
       "Notice Preference Definition       4\n",
       "Provided Email Address             2\n",
       "Year Patron Registered            14\n",
       "Outside of County                  2\n",
       "Supervisor District               11\n",
       "dtype: int64"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new.nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes</th>\n",
       "      <th>Missing Values Count</th>\n",
       "      <th>Missing Values %</th>\n",
       "      <th>Note</th>\n",
       "      <th>count unique</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Patron Code had 1-1 mapping and was subsequently dropped</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4274</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2738</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>object</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>215</td>\n",
       "      <td>0.000508</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>object</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Patron Code had 1-1 mapping and was subsequently dropped</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "      <td>110310</td>\n",
       "      <td>0.260504</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <td>datetime64[ns]</td>\n",
       "      <td>Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.</td>\n",
       "      <td>This column replaced both Circulation Active Month/Year</td>\n",
       "      <td>67904</td>\n",
       "      <td>0.160360</td>\n",
       "      <td>NaN</td>\n",
       "      <td>152</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   Data Type  \\\n",
       "Column Name                                    \n",
       "Patron Type Definition                object   \n",
       "Total Checkouts                        int64   \n",
       "Total Renewals                         int64   \n",
       "Age Range                             object   \n",
       "Home Library Definition               object   \n",
       "Notice Preference Definition          object   \n",
       "Provided Email Address                  bool   \n",
       "Year Patron Registered                 int64   \n",
       "Outside of County                       bool   \n",
       "Supervisor District                  float64   \n",
       "Circulation Active Date       datetime64[ns]   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "Circulation Active Date                                            Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.    \n",
       "\n",
       "                                                                                                                                                                                                                                Notes  \\\n",
       "Column Name                                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN   \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN   \n",
       "Total Renewals                                                                                                                                                                                                                    NaN   \n",
       "Age Range                                                                                                                                                                                                                         NaN   \n",
       "Home Library Definition                                                                                                                                                                                                           NaN   \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN   \n",
       "Provided Email Address                                                                                                                                                                                                            NaN   \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN   \n",
       "Outside of County                                                                                                                                                                                                                 NaN   \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...   \n",
       "Circulation Active Date                                                                                                                                                       This column replaced both Circulation Active Month/Year   \n",
       "\n",
       "                              Missing Values Count  Missing Values %  \\\n",
       "Column Name                                                            \n",
       "Patron Type Definition                           0          0.000000   \n",
       "Total Checkouts                                  0          0.000000   \n",
       "Total Renewals                                   0          0.000000   \n",
       "Age Range                                      215          0.000508   \n",
       "Home Library Definition                          0          0.000000   \n",
       "Notice Preference Definition                     0          0.000000   \n",
       "Provided Email Address                           0          0.000000   \n",
       "Year Patron Registered                           0          0.000000   \n",
       "Outside of County                                0          0.000000   \n",
       "Supervisor District                         110310          0.260504   \n",
       "Circulation Active Date                      67904          0.160360   \n",
       "\n",
       "                                                                                                           Note  \\\n",
       "Column Name                                                                                                       \n",
       "Patron Type Definition                                 Patron Code had 1-1 mapping and was subsequently dropped   \n",
       "Total Checkouts                                                                                             NaN   \n",
       "Total Renewals                                                                                              NaN   \n",
       "Age Range                                                                                                   NaN   \n",
       "Home Library Definition       Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped   \n",
       "Notice Preference Definition                           Patron Code had 1-1 mapping and was subsequently dropped   \n",
       "Provided Email Address                                                                                      NaN   \n",
       "Year Patron Registered                                                                                      NaN   \n",
       "Outside of County                                                                                           NaN   \n",
       "Supervisor District                                                                                         NaN   \n",
       "Circulation Active Date                                                                                     NaN   \n",
       "\n",
       "                              count unique  \n",
       "Column Name                                 \n",
       "Patron Type Definition                  18  \n",
       "Total Checkouts                       4274  \n",
       "Total Renewals                        2738  \n",
       "Age Range                               10  \n",
       "Home Library Definition                 35  \n",
       "Notice Preference Definition             4  \n",
       "Provided Email Address                   2  \n",
       "Year Patron Registered                  14  \n",
       "Outside of County                        2  \n",
       "Supervisor District                     11  \n",
       "Circulation Active Date                152  "
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new['count unique'] = library_new.nunique()\n",
    "library_dd_new"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Being efficient with categorical data\n",
    "Pandas has a specific data type for dealing with low-cardinality text columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index                                 80\n",
       "Patron Type Definition          26722568\n",
       "Age Range                       30022389\n",
       "Home Library Definition         28744750\n",
       "Circulation Active Date          3387584\n",
       "Total Checkouts                  3387584\n",
       "Total Renewals                   3387584\n",
       "Notice Preference Definition    26253773\n",
       "Provided Email Address            423448\n",
       "Year Patron Registered           3387584\n",
       "Outside of County                 423448\n",
       "Supervisor District              3387584\n",
       "dtype: int64"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new.memory_usage(deep=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Patron Type Definition                category\n",
       "Age Range                             category\n",
       "Home Library Definition               category\n",
       "Circulation Active Date         datetime64[ns]\n",
       "Total Checkouts                          int64\n",
       "Total Renewals                           int64\n",
       "Notice Preference Definition          category\n",
       "Provided Email Address                    bool\n",
       "Year Patron Registered                   int64\n",
       "Outside of County                         bool\n",
       "Supervisor District                    float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new = library_new.astype({'Patron Type Definition': 'category',\n",
    "                                  'Age Range': 'category',\n",
    "                                  'Home Library Definition': 'category',\n",
    "                                 'Notice Preference Definition': 'category'})\n",
    "library_new.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes</th>\n",
       "      <th>Missing Values Count</th>\n",
       "      <th>Missing Values %</th>\n",
       "      <th>Note</th>\n",
       "      <th>count unique</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>category</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Patron Code had 1-1 mapping and was subsequently dropped</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4274</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2738</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>category</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>215</td>\n",
       "      <td>0.000508</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>category</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>category</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Patron Code had 1-1 mapping and was subsequently dropped</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "      <td>110310</td>\n",
       "      <td>0.260504</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <td>datetime64[ns]</td>\n",
       "      <td>Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.</td>\n",
       "      <td>This column replaced both Circulation Active Month/Year</td>\n",
       "      <td>67904</td>\n",
       "      <td>0.160360</td>\n",
       "      <td>NaN</td>\n",
       "      <td>152</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   Data Type  \\\n",
       "Column Name                                    \n",
       "Patron Type Definition              category   \n",
       "Total Checkouts                        int64   \n",
       "Total Renewals                         int64   \n",
       "Age Range                           category   \n",
       "Home Library Definition             category   \n",
       "Notice Preference Definition        category   \n",
       "Provided Email Address                  bool   \n",
       "Year Patron Registered                 int64   \n",
       "Outside of County                       bool   \n",
       "Supervisor District                  float64   \n",
       "Circulation Active Date       datetime64[ns]   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "Circulation Active Date                                            Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.    \n",
       "\n",
       "                                                                                                                                                                                                                                Notes  \\\n",
       "Column Name                                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN   \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN   \n",
       "Total Renewals                                                                                                                                                                                                                    NaN   \n",
       "Age Range                                                                                                                                                                                                                         NaN   \n",
       "Home Library Definition                                                                                                                                                                                                           NaN   \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN   \n",
       "Provided Email Address                                                                                                                                                                                                            NaN   \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN   \n",
       "Outside of County                                                                                                                                                                                                                 NaN   \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...   \n",
       "Circulation Active Date                                                                                                                                                       This column replaced both Circulation Active Month/Year   \n",
       "\n",
       "                              Missing Values Count  Missing Values %  \\\n",
       "Column Name                                                            \n",
       "Patron Type Definition                           0          0.000000   \n",
       "Total Checkouts                                  0          0.000000   \n",
       "Total Renewals                                   0          0.000000   \n",
       "Age Range                                      215          0.000508   \n",
       "Home Library Definition                          0          0.000000   \n",
       "Notice Preference Definition                     0          0.000000   \n",
       "Provided Email Address                           0          0.000000   \n",
       "Year Patron Registered                           0          0.000000   \n",
       "Outside of County                                0          0.000000   \n",
       "Supervisor District                         110310          0.260504   \n",
       "Circulation Active Date                      67904          0.160360   \n",
       "\n",
       "                                                                                                           Note  \\\n",
       "Column Name                                                                                                       \n",
       "Patron Type Definition                                 Patron Code had 1-1 mapping and was subsequently dropped   \n",
       "Total Checkouts                                                                                             NaN   \n",
       "Total Renewals                                                                                              NaN   \n",
       "Age Range                                                                                                   NaN   \n",
       "Home Library Definition       Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped   \n",
       "Notice Preference Definition                           Patron Code had 1-1 mapping and was subsequently dropped   \n",
       "Provided Email Address                                                                                      NaN   \n",
       "Year Patron Registered                                                                                      NaN   \n",
       "Outside of County                                                                                           NaN   \n",
       "Supervisor District                                                                                         NaN   \n",
       "Circulation Active Date                                                                                     NaN   \n",
       "\n",
       "                              count unique  \n",
       "Column Name                                 \n",
       "Patron Type Definition                  18  \n",
       "Total Checkouts                       4274  \n",
       "Total Renewals                        2738  \n",
       "Age Range                               10  \n",
       "Home Library Definition                 35  \n",
       "Notice Preference Definition             4  \n",
       "Provided Email Address                   2  \n",
       "Year Patron Registered                  14  \n",
       "Outside of County                        2  \n",
       "Supervisor District                     11  \n",
       "Circulation Active Date                152  "
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new['Data Type'] = library_new.dtypes\n",
    "library_dd_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index                                80\n",
       "Patron Type Definition           425313\n",
       "Age Range                        424479\n",
       "Home Library Definition          427196\n",
       "Circulation Active Date         3387584\n",
       "Total Checkouts                 3387584\n",
       "Total Renewals                  3387584\n",
       "Notice Preference Definition     423855\n",
       "Provided Email Address           423448\n",
       "Year Patron Registered          3387584\n",
       "Outside of County                423448\n",
       "Supervisor District             3387584\n",
       "dtype: int64"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# huge decrease in memory\n",
    "library_new.memory_usage(deep=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example for Categorical Data\n",
    "* Use frequency counts for categorical data (non-graphical)\n",
    "* Bar charts (graphical)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ADULT          0.642938\n",
       "JUVENILE       0.139824\n",
       "SENIOR         0.098286\n",
       "YOUNG ADULT    0.068051\n",
       "WELCOME        0.035261\n",
       "Name: Patron Type Definition, dtype: float64"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new['Patron Type Definition'].value_counts(normalize=True).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1a1dee2828>"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAFjCAYAAADB6VcjAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3XmYXEW5x/HvjyCCIpssIgFBjSCL\nIEREUS+CIriBV5GACiqKekEBV1xxFwUXcEHxiiAugCuoKCC4i0pYBCNgImuEK0EQUVQE3/tHVSdn\nOt09p3oq6ZnJ7/M886T7dHf1mUn3ec+peustRQRmZmZtrDTqHTAzs6nDQcPMzFpz0DAzs9YcNMzM\nrDUHDTMza81Bw8zMWnPQMDOz1hw0zMysNQcNMzNrbeVR70Bt6667bmy66aaj3g0zsynl4osvvjUi\n1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S4Gn\nRsStXdvXA871qn5my5+vNGwyu093wIDF4xr3GcH+mK3wHDRsMrt7yMfMbBlx95RNWpLuBf7e6yFg\n1Yjw1YbZcuagYWZmrbl7yszMWnPQMDOz1hw0zMysNQcNMzNrzUHDzMxa+38QZpW4YBpUFAAAAABJ\nRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a1f958f28>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "library_new['Patron Type Definition'].value_counts().plot(kind='bar')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Categorical Outliers\n",
    "Categories with low counts can be examined further."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "ADULT                  272251\n",
       "JUVENILE                59208\n",
       "SENIOR                  41619\n",
       "YOUNG ADULT             28816\n",
       "WELCOME                 14931\n",
       "TEACHER CARD             1782\n",
       "DIGITAL ACCESS CARD      1744\n",
       "SPECIAL                   977\n",
       "STAFF                     862\n",
       "VISITOR                   415\n",
       "AT USER ADULT             349\n",
       "RETIRED STAFF             157\n",
       "BOOKS BY MAIL              95\n",
       "AT USER SENIOR             66\n",
       "AT USER JUVENILE           47\n",
       "AT USER WELCOME            45\n",
       "AT USER TEEN               44\n",
       "FRIENDS FOR LIFE           40\n",
       "Name: Patron Type Definition, dtype: int64"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new['Patron Type Definition'].value_counts()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create an extra column to label these as outliers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CategoricalIndex(['BOOKS BY MAIL', 'AT USER SENIOR', 'AT USER JUVENILE',\n",
       "                  'AT USER WELCOME', 'AT USER TEEN', 'FRIENDS FOR LIFE'],\n",
       "                 categories=['ADULT', 'AT USER ADULT', 'AT USER JUVENILE', 'AT USER SENIOR', 'AT USER TEEN', 'AT USER WELCOME', 'BOOKS BY MAIL', 'DIGITAL ACCESS CARD', ...], ordered=False, dtype='category')"
      ]
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new['Patron Type Definition'].value_counts().lt(100)[lambda x: x].index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [],
   "source": [
    "patron_outliers = ['BOOKS BY MAIL', 'AT USER SENIOR', 'AT USER JUVENILE',\n",
    "                   'AT USER WELCOME', 'AT USER TEEN', 'FRIENDS FOR LIFE']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>Age Range</th>\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <th>Total Checkouts</th>\n",
       "      <th>Total Renewals</th>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>Provided Email Address</th>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <th>Outside of County</th>\n",
       "      <th>Supervisor District</th>\n",
       "      <th>Patron Outliers</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SENIOR</td>\n",
       "      <td>65 to 74 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2012-11-01</td>\n",
       "      <td>28</td>\n",
       "      <td>13</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>55 to 59 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-10-01</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2015-01-01</td>\n",
       "      <td>275</td>\n",
       "      <td>559</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>True</td>\n",
       "      <td>NaN</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Mission Bay</td>\n",
       "      <td>2016-02-01</td>\n",
       "      <td>73</td>\n",
       "      <td>38</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>182</td>\n",
       "      <td>90</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>NaN</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Patron Type Definition       Age Range Home Library Definition  \\\n",
       "0                 SENIOR  65 to 74 years            Main Library   \n",
       "1                  ADULT  55 to 59 years            Main Library   \n",
       "2                  ADULT  60 to 64 years            Main Library   \n",
       "3                  ADULT  45 to 54 years             Mission Bay   \n",
       "4                  ADULT  45 to 54 years            Main Library   \n",
       "\n",
       "  Circulation Active Date  Total Checkouts  Total Renewals  \\\n",
       "0              2012-11-01               28              13   \n",
       "1              2015-10-01               21              10   \n",
       "2              2015-01-01              275             559   \n",
       "3              2016-02-01               73              38   \n",
       "4              2016-07-01              182              90   \n",
       "\n",
       "  Notice Preference Definition  Provided Email Address  \\\n",
       "0                        email                    True   \n",
       "1                        email                    True   \n",
       "2                        email                    True   \n",
       "3                        email                    True   \n",
       "4                        email                    True   \n",
       "\n",
       "   Year Patron Registered  Outside of County  Supervisor District  \\\n",
       "0                    2003               True                  NaN   \n",
       "1                    2003              False                  NaN   \n",
       "2                    2003               True                  NaN   \n",
       "3                    2003              False                  NaN   \n",
       "4                    2003              False                  NaN   \n",
       "\n",
       "   Patron Outliers  \n",
       "0            False  \n",
       "1            False  \n",
       "2            False  \n",
       "3            False  \n",
       "4            False  "
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new['Patron Outliers'] = library_new['Patron Type Definition'].isin(patron_outliers)\n",
    "library_new.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Univariate Analysis with Continuous data\n",
    "Good idea to start with describe method"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>161.982097</td>\n",
       "      <td>453.703678</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>113.0</td>\n",
       "      <td>35907.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>59.657327</td>\n",
       "      <td>225.009917</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>27.0</td>\n",
       "      <td>8965.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>2010.348917</td>\n",
       "      <td>4.357374</td>\n",
       "      <td>2003.0</td>\n",
       "      <td>2007.0</td>\n",
       "      <td>2012.0</td>\n",
       "      <td>2014.0</td>\n",
       "      <td>2016.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>6.288240</td>\n",
       "      <td>3.123634</td>\n",
       "      <td>1.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               mean         std     min     25%     50%  \\\n",
       "Total Checkouts          161.982097  453.703678     0.0     2.0    19.0   \n",
       "Total Renewals            59.657327  225.009917     0.0     0.0     2.0   \n",
       "Year Patron Registered  2010.348917    4.357374  2003.0  2007.0  2012.0   \n",
       "Supervisor District        6.288240    3.123634     1.0     4.0     6.0   \n",
       "\n",
       "                           75%      max  \n",
       "Total Checkouts          113.0  35907.0  \n",
       "Total Renewals            27.0   8965.0  \n",
       "Year Patron Registered  2014.0   2016.0  \n",
       "Supervisor District        9.0     11.0  "
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "summary_cont = library_new.describe().T.loc[:, 'mean':]\n",
    "summary_cont"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Possibly add 5 number summary to data dictionary\n",
    "But, it adds quite a bit messiness"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data Type</th>\n",
       "      <th>Definition</th>\n",
       "      <th>Notes</th>\n",
       "      <th>Missing Values Count</th>\n",
       "      <th>Missing Values %</th>\n",
       "      <th>Note</th>\n",
       "      <th>count unique</th>\n",
       "      <th>mean</th>\n",
       "      <th>std</th>\n",
       "      <th>min</th>\n",
       "      <th>25%</th>\n",
       "      <th>50%</th>\n",
       "      <th>75%</th>\n",
       "      <th>max</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Column Name</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <td>category</td>\n",
       "      <td>Description of patron (adult, teen, child, senior, etc.)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Patron Code had 1-1 mapping and was subsequently dropped</td>\n",
       "      <td>18</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Checkouts</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of items the patron has checked out from the library since the record was created.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4274</td>\n",
       "      <td>161.982097</td>\n",
       "      <td>453.703678</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>19.0</td>\n",
       "      <td>113.0</td>\n",
       "      <td>35907.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Total Renewals</th>\n",
       "      <td>int64</td>\n",
       "      <td>Total number of times the patron has renewed checked-out items.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2738</td>\n",
       "      <td>59.657327</td>\n",
       "      <td>225.009917</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>27.0</td>\n",
       "      <td>8965.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Age Range</th>\n",
       "      <td>category</td>\n",
       "      <td>Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>215</td>\n",
       "      <td>0.000508</td>\n",
       "      <td>NaN</td>\n",
       "      <td>10</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Home Library Definition</th>\n",
       "      <td>category</td>\n",
       "      <td>Description of the branch library where the patron was originally registered.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped</td>\n",
       "      <td>35</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <td>category</td>\n",
       "      <td>Description of the patron’s preferred method of receiving library notices.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Patron Code had 1-1 mapping and was subsequently dropped</td>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Provided Email Address</th>\n",
       "      <td>bool</td>\n",
       "      <td>Indicates whether the patron provided an email address</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <td>int64</td>\n",
       "      <td>Year patron registered with library system. No dates prior to 2003 due to system migration.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>14</td>\n",
       "      <td>2010.348917</td>\n",
       "      <td>4.357374</td>\n",
       "      <td>2003.0</td>\n",
       "      <td>2007.0</td>\n",
       "      <td>2012.0</td>\n",
       "      <td>2014.0</td>\n",
       "      <td>2016.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Outside of County</th>\n",
       "      <td>bool</td>\n",
       "      <td>If a patron's home address is not in San Francisco, then flagged as true, otherwise false.</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Supervisor District</th>\n",
       "      <td>float64</td>\n",
       "      <td>Based on patron address: San Francisco Supervisor District.</td>\n",
       "      <td>This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...</td>\n",
       "      <td>110310</td>\n",
       "      <td>0.260504</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11</td>\n",
       "      <td>6.288240</td>\n",
       "      <td>3.123634</td>\n",
       "      <td>1.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <td>datetime64[ns]</td>\n",
       "      <td>Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.</td>\n",
       "      <td>This column replaced both Circulation Active Month/Year</td>\n",
       "      <td>67904</td>\n",
       "      <td>0.160360</td>\n",
       "      <td>NaN</td>\n",
       "      <td>152</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   Data Type  \\\n",
       "Column Name                                    \n",
       "Patron Type Definition              category   \n",
       "Total Checkouts                        int64   \n",
       "Total Renewals                         int64   \n",
       "Age Range                           category   \n",
       "Home Library Definition             category   \n",
       "Notice Preference Definition        category   \n",
       "Provided Email Address                  bool   \n",
       "Year Patron Registered                 int64   \n",
       "Outside of County                       bool   \n",
       "Supervisor District                  float64   \n",
       "Circulation Active Date       datetime64[ns]   \n",
       "\n",
       "                                                                                                                                                                                                           Definition  \\\n",
       "Column Name                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                       Description of patron (adult, teen, child, senior, etc.)   \n",
       "Total Checkouts                                                                                                       Total number of items the patron has checked out from the library since the record was created.   \n",
       "Total Renewals                                                                                                                                        Total number of times the patron has renewed checked-out items.   \n",
       "Age Range                     Age ranges: 0 to 9 years, 10 to 19 years, 20 to 24 years, 25 to 34 years, 35 to 44 years, 45 to 54 years, 55 to 59 years, 60 to 64 years 65 to 74 years, 75 years and over. Some blank.   \n",
       "Home Library Definition                                                                                                                 Description of the branch library where the patron was originally registered.   \n",
       "Notice Preference Definition                                                                                                               Description of the patron’s preferred method of receiving library notices.   \n",
       "Provided Email Address                                                                                                                                         Indicates whether the patron provided an email address   \n",
       "Year Patron Registered                                                                                                    Year patron registered with library system. No dates prior to 2003 due to system migration.   \n",
       "Outside of County                                                                                                          If a patron's home address is not in San Francisco, then flagged as true, otherwise false.   \n",
       "Supervisor District                                                                                                                                       Based on patron address: San Francisco Supervisor District.   \n",
       "Circulation Active Date                                            Date the patron last checked out library materials, or last logged into the library's subscription databases from a computer outside the library.    \n",
       "\n",
       "                                                                                                                                                                                                                                Notes  \\\n",
       "Column Name                                                                                                                                                                                                                             \n",
       "Patron Type Definition                                                                                                                                                                                                            NaN   \n",
       "Total Checkouts                                                                                                                                                                                                                   NaN   \n",
       "Total Renewals                                                                                                                                                                                                                    NaN   \n",
       "Age Range                                                                                                                                                                                                                         NaN   \n",
       "Home Library Definition                                                                                                                                                                                                           NaN   \n",
       "Notice Preference Definition                                                                                                                                                                                                      NaN   \n",
       "Provided Email Address                                                                                                                                                                                                            NaN   \n",
       "Year Patron Registered                                                                                                                                                                                                            NaN   \n",
       "Outside of County                                                                                                                                                                                                                 NaN   \n",
       "Supervisor District           This is an automated field, please note that if \"Outside of County\" is true, then there will be no supervisor district. Also, if the input address was not well-formed, the supervisor district will...   \n",
       "Circulation Active Date                                                                                                                                                       This column replaced both Circulation Active Month/Year   \n",
       "\n",
       "                              Missing Values Count  Missing Values %  \\\n",
       "Column Name                                                            \n",
       "Patron Type Definition                           0          0.000000   \n",
       "Total Checkouts                                  0          0.000000   \n",
       "Total Renewals                                   0          0.000000   \n",
       "Age Range                                      215          0.000508   \n",
       "Home Library Definition                          0          0.000000   \n",
       "Notice Preference Definition                     0          0.000000   \n",
       "Provided Email Address                           0          0.000000   \n",
       "Year Patron Registered                           0          0.000000   \n",
       "Outside of County                                0          0.000000   \n",
       "Supervisor District                         110310          0.260504   \n",
       "Circulation Active Date                      67904          0.160360   \n",
       "\n",
       "                                                                                                           Note  \\\n",
       "Column Name                                                                                                       \n",
       "Patron Type Definition                                 Patron Code had 1-1 mapping and was subsequently dropped   \n",
       "Total Checkouts                                                                                             NaN   \n",
       "Total Renewals                                                                                              NaN   \n",
       "Age Range                                                                                                   NaN   \n",
       "Home Library Definition       Home library code had nearly 1-1 mapping except for Unknown, but was stil dropped   \n",
       "Notice Preference Definition                           Patron Code had 1-1 mapping and was subsequently dropped   \n",
       "Provided Email Address                                                                                      NaN   \n",
       "Year Patron Registered                                                                                      NaN   \n",
       "Outside of County                                                                                           NaN   \n",
       "Supervisor District                                                                                         NaN   \n",
       "Circulation Active Date                                                                                     NaN   \n",
       "\n",
       "                              count unique         mean         std     min  \\\n",
       "Column Name                                                                   \n",
       "Patron Type Definition                  18          NaN         NaN     NaN   \n",
       "Total Checkouts                       4274   161.982097  453.703678     0.0   \n",
       "Total Renewals                        2738    59.657327  225.009917     0.0   \n",
       "Age Range                               10          NaN         NaN     NaN   \n",
       "Home Library Definition                 35          NaN         NaN     NaN   \n",
       "Notice Preference Definition             4          NaN         NaN     NaN   \n",
       "Provided Email Address                   2          NaN         NaN     NaN   \n",
       "Year Patron Registered                  14  2010.348917    4.357374  2003.0   \n",
       "Outside of County                        2          NaN         NaN     NaN   \n",
       "Supervisor District                     11     6.288240    3.123634     1.0   \n",
       "Circulation Active Date                152          NaN         NaN     NaN   \n",
       "\n",
       "                                 25%     50%     75%      max  \n",
       "Column Name                                                    \n",
       "Patron Type Definition           NaN     NaN     NaN      NaN  \n",
       "Total Checkouts                  2.0    19.0   113.0  35907.0  \n",
       "Total Renewals                   0.0     2.0    27.0   8965.0  \n",
       "Age Range                        NaN     NaN     NaN      NaN  \n",
       "Home Library Definition          NaN     NaN     NaN      NaN  \n",
       "Notice Preference Definition     NaN     NaN     NaN      NaN  \n",
       "Provided Email Address           NaN     NaN     NaN      NaN  \n",
       "Year Patron Registered        2007.0  2012.0  2014.0   2016.0  \n",
       "Outside of County                NaN     NaN     NaN      NaN  \n",
       "Supervisor District              4.0     6.0     9.0     11.0  \n",
       "Circulation Active Date          NaN     NaN     NaN      NaN  "
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_dd_new.join(summary_cont)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Get a sense of the distribution\n",
    "Histograms are great for this"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1a1247b358>"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZsAAAD8CAYAAAChHgmuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAHFxJREFUeJzt3X+QXfV53/H3xxK//AMkYKEaSUSy\nvRNbMEbAGtQ6TR1hwyInFs5AKyYTNFSNUltM7TptEU4n4B/qQFpHLo2NIwcFiTgWMraDaovIMj/i\nZoqRFiMLCUy0FhTW0iBhiR8OQUTw9I/zrH203L17d7Xfvcvyec2cuec85/s95zmHXT2cc757riIC\nMzOzkt7U7gTMzGzic7ExM7PiXGzMzKw4FxszMyvOxcbMzIpzsTEzs+JcbMzMrDgXGzMzK87FxszM\nipvc7gTGi1NPPTVmzZrV7jTMzF5XHnzwwWciomOodi42adasWfT09LQ7DTOz1xVJ/6+Vdr6NZmZm\nxbnYmJlZcS42ZmZWnIuNmZkVV7zYSJok6SFJ387l2ZIekLRL0u2Sjs34cbncm+tn1bZxbcYfk3Rx\nLd6dsV5Jy2vxhvswM7P2GIsrm48Dj9aWbwRWRkQncBBYkvElwMGIeCewMtshaQ6wCDgT6Aa+lAVs\nEvBF4BJgDnBFtm22DzMza4OixUbSDOBDwJ/nsoD5wB3ZZA1wac4vzGVy/YXZfiGwLiIORcTjQC9w\nfk69EbE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zlHQWcC3wLuC9VLfGrml3no242Bydll6LU1pE7MnPfcC3\nqH5Zns7LYvJzXzYfLOexOpbRyqsv54vlGxFP5y/3q8BXqM7rSHJ9huoWxuQB8RGRdAzVP+BfjYhv\nZnjcnddGeY7Xc9ovIp4F7qN6xjHY9n+RU64/ieoW7Jj9btXy7M5blhERh4C/YOTntOzv1Gg9/Hkj\nTlR/FLub6mFg/4O/M8c4h7cAb6vN/1+qZy3/nSMfGP9xzn+IIx8absn4ycDjVA8Mp+b8yaOQ3yyO\nfOg+anlRvZZoHr98mLlglHOdVpv/j1T34wHO5MgHwbupHgIP+vMAfJ0jHzZ/bIQ5iupe+hcGxMfV\neW2S53g8px3AlJw/Afg/wG8Otn1gGUcOEFg/0mMYpTyn1c75F4Abxsvv1BH5j9aG3qgT1YiPv6e6\nx/uHbdj/2/OH90fAzv4cqO4h3w3sys/+HyZRfbHcT4CHga7atv4t1UPNXuCqUcjta1S3Sv6J6v+a\nloxmXkAXsCP7/Cn5R8qjmOttmct2qnfr1f+h/MPc72PURuwM9vOQ/5225DF8HThuhHn+GtWtje3A\ntpwWjLfz2iTP8XhO3wM8lDntAP6o2faB43O5N9e/faTHMEp53pPndAfwl/xyxFpbf6cGTn6DgJmZ\nFednNmZmVpyLjZmZFediY2ZmxbnYmJlZcS42ZmZWnIuNmZkV52JjZmbFudiYmVlx/x/jAeLVCK1h\npQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a124725c0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "library_new['Total Checkouts'].plot(kind='hist', bins=50)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Looks like there are some extreme outliers here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/Ted/anaconda3/lib/python3.6/site-packages/seaborn/categorical.py:462: FutureWarning: remove_na is deprecated and is a private function. Do not use.\n",
      "  box_data = remove_na(group_data)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x1a12f7ca58>"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWQAAAEKCAYAAAAl5S8KAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAElFJREFUeJzt3X+QVeV9x/HPF3ZB648EgTiITla7\n0x+adgxubGw1OhYalqZip/6RGTMySZVpkzLV2iFG1rCMZEbtRKOmhaKTBNpMEk0CExuXEWob7aZI\nFgOISc2uSqYqPxZwW6Cy7I9v/zjPXe8u9979de/le+P7NbOz5zz3nOd878O9H8597r1nzd0FADj9\nppzuAgAAGQIZAIIgkAEgCAIZAIIgkAEgCAIZAIIgkAEgCAIZAIIgkAEgiLrxbDxr1ixvaGioUCkA\n8Ktpx44dh9x99mjbjSuQGxoa1NHRMfGqAOA9yMx+OZbtmLIAgCAIZAAIgkAGgCAIZAAIgkAGgCAI\nZAAIgkAGgCAIZAAIgkAGgCAIZAAIgkAGgCAIZAAIgkAGgCAIZAAIgkAGgCAIZAAIgkAGgCAIZAAI\ngkAGgCDG9Tf1JurWW29VT0+Prr32Wi1btqwahwSAmlOVQN63b5+OHz+urq6uahwOAGoSUxYAEASB\nDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABB\nEMgAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgA\nEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASB\nDABBEMgAEASBDABBVCWQe3t7JUlvvvmmHn300WocEgBqTlUCeXBwUJL0zjvvqKurqxqHBICaw5QF\nAARBIANAEAQyAARBIANAEAQyAARBIANAEAQyAARBIANAEAQyAARBIANAEAQyAARBIANAEAQyAARB\nIANAEAQyAARBIANAEAQyAARBIANAEAQyAARBIANAEAQyAARBIANAEAQyAARBIANAEAQyAARBIANA\nEAQyAARBIANAEAQyAARBIANAEAQyAARBIANAEAQyAARBIANAEAQyAARBIANAEAQyAARBIANAEHXV\nPNjx48e1a9cuXXfdddU8bFj19fWaMmWKZsyYof3798vMdMEFF6i7u1snT56UmWnKlCkaGBiQJNXV\n1WlgYEB33HGH1qxZozlz5mj69Om688479eCDD+rkyZOaNm2abrrpJq1evVq33XabHnvsMd1zzz3a\nuHGjVq5cKUlqaWnRiRMndODAAT3yyCNqbGwcVldHR4eWL1+ulpYWbdq0aWi/VatWaeXKlZo5c6YO\nHz48bD2nWHv+7S0tLTIz3XvvvSX7KmQsxx1Za60Z63iMZ9wwcdUc56mtra1j3njdunWtS5cuHfdB\n1q9fL3cf936/6gYHBzUwMKBjx44NtR09enQogCUNG7fBwUFJ0rZt29TX16e3335bhw4d0u7du9XZ\n2akjR46ou7tb7e3tGhgY0I4dO+Tuam9v1/79+3XixAnt3LlT7e3t6unpUV9fn3bv3q0bb7xxWF1L\nly5Vb2/vKfs9//zzOnHihK666iqtXbt22HpOsfb829vb29Xd3a3e3t6SfRUyluOOrLXWjHU8xjNu\nmLhyjPOqVav2tba2rhttO6YsatDI/9z27t07bL2/v/+UdXdXW1ubnn766VP27erqGlrv6OgY+g8i\nf7/NmzfL3bV582Z1dXUNWz98+LCk7EyiUHvO4cOH1dbWNrTe1tZWtK9CivWf3z6y1lL9RTTaGI53\nO0xOtceZQH4P6evrOyWsJWn16tVDy4VeMfX19amvr0+SNDAwoNWrVw+drQ8MDGjDhg2SsldChdpz\n1q9fP+z4fX19RfsqpFj/+e0jay3VX0SjjeF4t8PkVHucRw1kM1t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z\n9gdmX1R2xbVS/bqZLZb0sJmtkPSOsksg3q7sMo2F9uk1s5skPWJm5yh7fH9Z2dn2zcqmEb6k7Iz4\nz/L222dmN0h62sxukfRFSV83s92Sjkn6dNr0SUmfMrOfKruK2Wtp/wMj7usvJP2NmfWl/T81+kgC\n4mpvABAFUxYAEASBDABBEMgAEASBDABBEMgAEASBDABBEMgAEASBDABB/D+ObgXHUG7puAAAAABJ\nRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a294b2518>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.boxplot('Total Checkouts',  data=library_new)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Choose a cut-off and examine those points later"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0009729648032343994"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(library_new['Total Checkouts'] > 5000).mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Can add these as outliers again"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [],
   "source": [
    "library_new['Outlier Total Checkouts'] = library_new['Total Checkouts'] > 5000"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Filter for outliers:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Patron Type Definition</th>\n",
       "      <th>Age Range</th>\n",
       "      <th>Home Library Definition</th>\n",
       "      <th>Circulation Active Date</th>\n",
       "      <th>Total Checkouts</th>\n",
       "      <th>Total Renewals</th>\n",
       "      <th>Notice Preference Definition</th>\n",
       "      <th>Provided Email Address</th>\n",
       "      <th>Year Patron Registered</th>\n",
       "      <th>Outside of County</th>\n",
       "      <th>Supervisor District</th>\n",
       "      <th>Patron Outliers</th>\n",
       "      <th>Outlier Total Checkouts</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>319</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>Ortega</td>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>5673</td>\n",
       "      <td>208</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>4.0</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>334</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>45 to 54 years</td>\n",
       "      <td>Ortega</td>\n",
       "      <td>2014-07-01</td>\n",
       "      <td>5158</td>\n",
       "      <td>201</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>9.0</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>558</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>Main Library</td>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>10521</td>\n",
       "      <td>621</td>\n",
       "      <td>phone</td>\n",
       "      <td>False</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>6.0</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>679</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>Richmond</td>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>6335</td>\n",
       "      <td>375</td>\n",
       "      <td>phone</td>\n",
       "      <td>False</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>11.0</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>758</th>\n",
       "      <td>ADULT</td>\n",
       "      <td>60 to 64 years</td>\n",
       "      <td>Mission</td>\n",
       "      <td>2015-06-01</td>\n",
       "      <td>5040</td>\n",
       "      <td>2063</td>\n",
       "      <td>email</td>\n",
       "      <td>True</td>\n",
       "      <td>2003</td>\n",
       "      <td>False</td>\n",
       "      <td>9.0</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Patron Type Definition       Age Range Home Library Definition  \\\n",
       "319                  ADULT  60 to 64 years                  Ortega   \n",
       "334                  ADULT  45 to 54 years                  Ortega   \n",
       "558                  ADULT  60 to 64 years            Main Library   \n",
       "679                  ADULT  60 to 64 years                Richmond   \n",
       "758                  ADULT  60 to 64 years                 Mission   \n",
       "\n",
       "    Circulation Active Date  Total Checkouts  Total Renewals  \\\n",
       "319              2016-07-01             5673             208   \n",
       "334              2014-07-01             5158             201   \n",
       "558              2016-07-01            10521             621   \n",
       "679              2016-07-01             6335             375   \n",
       "758              2015-06-01             5040            2063   \n",
       "\n",
       "    Notice Preference Definition  Provided Email Address  \\\n",
       "319                        email                    True   \n",
       "334                        email                    True   \n",
       "558                        phone                   False   \n",
       "679                        phone                   False   \n",
       "758                        email                    True   \n",
       "\n",
       "     Year Patron Registered  Outside of County  Supervisor District  \\\n",
       "319                    2003              False                  4.0   \n",
       "334                    2003              False                  9.0   \n",
       "558                    2003              False                  6.0   \n",
       "679                    2003              False                 11.0   \n",
       "758                    2003              False                  9.0   \n",
       "\n",
       "     Patron Outliers  Outlier Total Checkouts  \n",
       "319            False                     True  \n",
       "334            False                     True  \n",
       "558            False                     True  \n",
       "679            False                     True  \n",
       "758            False                     True  "
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "library_new[library_new['Outlier Total Checkouts']].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Continue with checklist\n",
    "* Multivariate Analysis\n",
    "* Check for duplicated rows\n",
    "* Bootstrap to get more samples"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
